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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

int main(){
  ll n; cin >> n;
  string s; cin >> s;
  ll ans = INF;
  Vi temp(n + 1, 0);
  REP(i, n){
    if(s[i] == '#') temp[0]++;
  }
  chmin(ans, temp[0]);
  REP(i, n){
    if(s[n - i- 1] == '#'){
      temp[i + 1] = temp[i] - 1;
    }
    else {
      temp[i + 1] = temp[i] + 1;
    }
    chmin(ans, temp[i + 1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 2180
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
const ll INF = (ll)1e18 + 1;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    double t, x; cin >> t >> x;

    cout << t/x << ln;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

//拡張ユークリッド
//ax+by=gcd(a,b)の解
ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d=a;
	if(b){
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1,y=0;
	}
	return d;
}

//中国剰余定理
//https://qiita.com/drken/items/ae02240cd1f8edfc86fd
//リターン値 (r,m) x¥equiv r (mod m)
pair<long long, long long> ChineseRem(const vector<long long> &b, const vector<long long> &m) {
  long long r = 0, M = 1;
  for (int i = 0; i < (int)b.size(); ++i) {
    long long p, q;
    long long d = extgcd(M, m[i], p, q); // p is inv of M/d (mod. m[i]/d)
    if ((b[i] - r) % d != 0) return make_pair(0, -1);
    long long tmp = (b[i] - r) / d * p % (m[i]/d);
    r += M * tmp;
    M *= m[i]/d;
  }
  return make_pair((r%M+M)%M, M);
}

//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    n*=2;
    ll ans=inf;
    for(auto x:divisor(n)){
        vector<ll> b={0,-1},m={x,n/x};
        P ret=ChineseRem(b,m);
        if(ret.se==-1) continue;
        if(ret.fi==0) ret.fi+=ret.se;
        chmin(ans,ret.fi);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3752
h,n=map(int,input().split())
A=list(map(int,input().split()))
if sum(A)<h:
    print('No')
    
else:
    summ=0
    for i in A:
        h-=i
        if h<=0:
            print('Yes')
            break
    if h>0:
        print('No')

Measured memory_bytes: 13964
from collections import defaultdict as dict

s = input()
a = []
for c in s:
    a.append(int(c))

cnt = dict(int)
d = 1
a.reverse()
y = 0
cnt[y] += 1
ans = 0
for x in a:
    y += d*x
    y %= 2019
    ans += cnt[y]
    cnt[y] += 1
    d *= 10
    d %= 2019

print(ans)

Measured memory_bytes: 75032
N = int(input())
L = list(map(int, input().split()))

res = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            tmp = sorted([L[i], L[j], L[k]])
            if tmp[0] < tmp[1] < tmp[2] and (tmp[0] + tmp[1]) > tmp[2]:
                res += 1
print(res)


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

using namespace std;

typedef long long int int64;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++) {
		int inp;
		cin >> inp;
		if(inp % 2 == 0) {
			if(inp % 5 != 0 && inp % 3 != 0) {
				cout << "DENIED\n";
				return 0;
			}
		}
	}
	cout << "APPROVED\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int n, i;
	cin >> n >> i;

	cout << n - i + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
def out(s, depth)
  (1..depth).each do |_|  print ' ' end
  puts s
end

def solve(n, hn, depth)
  return 0 if n == 0

  hn_bk = Array.new(hn)

  min = hn.min
  if n == 1
    #out("solve(#{n} #{hn}) = #{min}", depth)
    return min
  end

  (0..n-1).each { |i| hn[i] -= min}

  start = hn[0] == 0 ? 1 : 0
  i = start
  ans = 0
  while i < n do
    if hn[i] == 0
      tmp = solve(i - start, hn[start..(i-1)], depth + 1)
      ans += tmp
      start = i + 1
    end

    i += 1
  end
  if hn[i-1] != 0
    ans += solve(i - start, hn[start..(i-1)], depth + 1)
  end

  #out("solve(#{n}, #{hn_bk}) = solve(#{n}, #{hn}) + min = #{ans} + #{min}", depth)

  min + ans
end

n = gets.to_i
hn = gets.split.map(&:to_i)

puts solve(n, hn, 0)


Measured memory_bytes: 1788
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#define ll long long
#define ld long double
using namespace std;

int main() {
    vector<int> all;
    int n, in;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> in;
        all.push_back(in);
    }

    int index=0;
    vector<int>::iterator v = all.begin();
    while (v != all.end()) {
        if (*v==index+1)
            index++;
        v++;
    }

    if (index!=0)
    cout << all.size() - index;
    else cout << -1;

    return 0;
}


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

int main(){
	int n;cin>>n;
	vector<int>v;
	for(int i=0;i<n;i++){
		int a;cin>>a;
		v.push_back(a);
	}
	for(int i=0;i<n;i++){
		if(v[i]%2){
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
	return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint n, x, d;
  cin >> n >> x >> d;
  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n + 1 << endl;
    }
    return 0;
  }
  // if (d < 0) {
  //   x = -x;
  //   d = -d;
  // }
  unordered_map<int, vector<pair<lint, lint>>> now;
  for (lint A = 0; A <= n; ++A) {
    // S = Ax + Bd
    lint Bmin = (A - 1) * A / 2, Bmax = (2 * n - A - 1) * A / 2;
    lint Adiv = A * x / d, Smod = A * x % d;
    if (Smod < 0) {
      Smod += abs(d);
      // ++Adiv;
    }
    now[Smod].push_back({Adiv + Bmin, Adiv + Bmax});
  }
  lint cnt = 0;
  allrep (m, now) {
    sort(all(m.second));
    lint now = LLONG_MIN;
    allrep (p, m.second) {
      lint l = max(now, p.first), r = max(now, p.second + 1);
      cnt += r - l;
      now  = r;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> s(m);
  vector<int> c(m);
  rep(i,m) {
    cin >> s[i] >> c[i];
  }
  
  int ans = 0;
  vector<int> num(n, -1);
  rep(i, m) {
    if (num[s[i]-1] == -1) {
      num[s[i]-1] = c[i];
    }
    if (num[s[i]-1] != c[i]) {
      ans = -1;
      break;
    }
  }
  
  if (n == 1 && ans == 0) {
    if (num[0] == -1) {
      ans = 0;
    } else {
      ans = num[0];
    }
  } else if (ans == 0) {
    if (num[0] == 0) {
      ans = -1;
    } else {
      rep(i, n) {
        if (num[i] == -1) {
          if (i == 0) {
            num[i] = 1;
          } else {
            num[i] = 0;
          }
        }
      }
      ans = 0;
      rep(i, n) {
        ans += pow(10, n-i-1) * num[i];
      }
    }
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int data,a,b,c,i;
	
	scanf("%d",&data);
	
	for(i=0;i<data;i++){
		scanf("%d %d %d",&a,&b,&c);
		if((c*c)==((a*a)+(b*b)) || (a*a)==((b*b)+(c*c)) || (b*b)==((a*a)+(c*c)))
			printf("YES\n");
		else
			printf("NO\n");
	}
	
	return 0;

}

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

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

    bool flag = true;
    for(int i=x;i<pow(10,6);i++)
    {
        bool flag = true;
        for(int j=2;j<sqrt(i);j++)
        {
            if(i%j==0)
            {
                flag = false;
                continue;
            }
        }
        if(flag)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    
    return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


vector<int> go(int N, ll left, const vector<ll> &A, int start) {
    map<ll, int> s;
    vector<int> stk;
    stk.reserve(N);
    for(ll i = start; left > 0; i++, left--) {
        ll a = A[i % N];
        if(s[a] > 0) {
            int sa = s[a];
            while(stk.size() >= sa) {
                s[stk.back()] = 0;
                stk.pop_back();
            }
        } else {
            stk.push_back(a);
            s[a] = stk.size();
        }
        // cerr << i << ": " << stk << endl;
    }
    return stk;
}

int main() {
    int N; ll K; cin >> N >> K;
    vector<ll> A(N); cin >> A;

    vector<int> next_index(N);
    map<ll, int> last;
    for(int i = N * 2 - 1; i >= 0; i--) {
        if(i < N) next_index[i] = last[A[i]];
        last[A[i%N]] = i % N;
    }
    //debug(next_index);
    ll left = K * N;
    vector<int> visited(N, -1);
    vector<ll> log;
    log.reserve(N);
    log.push_back(0);
    int now = 0;
    while(left > N) {
        if(visited[now] >= 0) {
            // cerr << "LOOP at " << now << endl;
            ll sum = log.back() - log[visited[now] - 1];
            // cerr << "sum = " << sum << " left = " << left << endl;
            left = left % sum;
        }
        int next = next_index[now];
        ll diff = (next <= now ? next + N - now : next - now) + 1;
        if(diff > left) break;
        left -= diff;
        // cerr << now << " -> " << (next + 1) % N << " (+" << diff << "), left " << left << endl;
        visited[now] = log.size();
        now = (next + 1) % N;
        log.push_back(diff + log.back());
    }
    // debug(left);
    // debug(now);
    // debug((left + now) % N);
    //assert((left + now) % N == 0);
    // cerr << "go (left = " << left << " at " << now << endl;
    auto ans =  go(N, left, A, now);
    rep(i, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 30464
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
aabbaa
---+/
/+---test
aaaccacabaababc
---+/

void main(string[] args) {
  const S = readln.chomp;

  long ans;
  string prev;
  string cur;
  foreach (i, s; S) {
    cur ~= s;
    if (cur != prev) {
      prev = cur;
      cur  = "";
      ++ans;
    }
  }
  ans.writeln;
}


Measured memory_bytes: 3512
#include <set>
#include <map>
#include <math.h>
#include <vector>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
const double pi = acos(-1);
const double g = -9.8;



int main()
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a+b==c+d){
		printf("Balanced\n");
	}else if(a+b>c+d){
		printf("Left\n");
	}else
		printf("Right\n");
}



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

using P=pair<int,int>;
using ll=long long;

struct L{
  int a,b,c;
  L(int a=0,int b=0,int c=0): a(a),b(b),c(c){}
};

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

int main(){

  int n,m;//縦横線の数
  cin >> n >>m;

  map<int,int> mpX,mpY;
  mpX[0]=0;
  mpY[0]=0;

  vector<L> lh,lv;//線分の情報
  for(int i=0;i<n;i++){
    int a,b,c;
    cin >> a >> b >> c;
    mpX[a]=0;
    mpX[b]=0;
    mpY[c]=0;
    lh.emplace_back(a,b,c);
  }
  for(int i=0;i<m;i++){
    int a,b,c;
    cin >> c >> a >> b;
    mpY[a]=0;
    mpY[b]=0;
    mpX[c]=0;
    lv.emplace_back(a,b,c);
  }

  //圧縮座用配列を作る
  vector<int> xs,ys;
  //mapがキーでsortされてるから、x、yがそれぞれ小さい順に抜き出されて入れられる
  //mpX,mpYのsecondは０で使用してないからxsのindexを入れて紐づけてる
  //→xs[i]=mpXのsecondがiになるとこのfirst
  for(auto& p:mpX){
    p.second=xs.size();
    xs.push_back(p.first);
  }
  for(auto& p:mpY){
    p.second=ys.size();
    ys.push_back(p.first);
  }

  int h = xs.size()*2;//xの個数とそれと同等の線のマスがあれば十分
  int w = ys.size()*2;

  vector<vector<int>> dist(h,vector<int>(w));
  //2の倍数が線のマス、a,b,cはさっき入れたインデックス
  //→index=座標圧縮されたグリットのx,y座標
  for(int i=0;i<n;i++){
    int a = mpX[lh[i].a]*2;
    int b = mpX[lh[i].b]*2;
    int c = mpY[lh[i].c]*2;
    for(int x=a;x<=b;x++) dist[x][c]=-1;//壁を塗ってる
  }
  for(int i=0;i<m;i++){
    int a = mpY[lv[i].a]*2;
    int b = mpY[lv[i].b]*2;
    int c = mpX[lv[i].c]*2;
    for(int y=a;y<=b;y++) dist[c][y]=-1;
  }



  //dfsして塗りつぶす
  queue<P> que;
  int sx=mpX[0]*2,sy=mpY[0]*2;//原点は線上だから*2,ここで使うから最初にmp[０]が必要
  dist[sx][sy]=1;
  que.push({sx,sy});
  while(!que.empty()){
    int x,y;
    x = que.front().first;
    y = que.front().second;
    que.pop();

    for(int i=0;i<4;i++){
      int nx = x+dx[i];
      int ny = y+dy[i];

      if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
      if(dist[nx][ny]!=0) continue;
      dist[nx][ny]=1;
      que.push({nx,ny});
    }
  }

  ll ans = 0;
  //0,1,-1に塗り分けられてて、それぞれ行けないとこ、行けるとこ、線分が引いてあるとこ
  for(int y=0;y<w;y++){
    for(int x=0;x<h;x++){
      if(dist[x][y]!=1) continue;
      //外枠がにdist[]=1が存在する
      //→閉路がない→INF
      if(x==0 || x==h-1 || y==0 || y==w-1){
        cout << "INF" << endl;
        return 0;//終了
      }
      if(x%2 == 0 || y%2 == 0) continue;
      ll ex = xs[x/2+1]-xs[x/2];
      ll ey = ys[y/2+1]-ys[y/2];
      ans+=ex*ey;
    }
  }
  cout << ans << endl;


}

Measured memory_bytes: 144504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    string S;
    cin >> S;
    int l = S.size();
    rep(i,l){
        if(S.at(i)=='?'){
            cout << 'D';
        }else{
            cout << S.at(i);
        }
    }
    cout << endl;
}

Measured memory_bytes: 3752
from collections import deque
q = deque()
h,w=map(int,input().split())
sx,sy=1,1#スタート位置
ex,ey=h,w#ゴール位置
q.append([sx-1,sy-1,0])
global finished 
finished = set()
c=[]
for i in range(h):
    c.append(list(map(str,input())))

def check(x,y):
    if 0<=x and x<h:
        if 0<=y and y<w:
            return True
    return False

count=0
def search():
    while (q):
        x,y,count=q.popleft()
        
        if check(x,y)==False or (x,y) in finished or c[x][y]=='#':
            continue
        else:
            q.append([x,y-1,count+1])
            q.append([x,y+1,count+1])
            q.append([x+1,y,count+1])
            q.append([x-1,y,count+1])
            finished.add((x,y))
            c[x][y]=count
            if x==ex-1 and y==ey-1:
                return c[x][y]+1 #通った道の合計を返す
    return -1
black_count=0
for i in range(h):
    black_count+=c[i].count("#")
path=search()#通る道
if path==-1:
    print(path)
else:
    print(h*w-black_count-path)#全体からもともと黒の#の数と通った白い道を削除


Measured memory_bytes: 3700
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 3e5 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r; 
}
void solve()
{
	int n;
	cin >> n;
	ll a[n];
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	int cnt = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			for(int k = j + 1; k < n; ++k){
				if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
				if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i]) cnt++;
			}
		}
	}
	cout << cnt;
}
 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

Measured memory_bytes: 3656
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [a,b] <- readInts
  print . showAnswer $ solve (a,b)

type Input  = (Int, Int)
type Output = Int

solve :: Input -> Output
solve (a,b) = (a-1) * (b-1)

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n, a, b;

int main(void) {
  // Here your code !
  scanf("%d", &n);
  
  if (n == 1) printf("Hello World\n");
  else {
    scanf("%d", &a);
    scanf("%d", &b);
    
    printf("%d\n", a + b);
  }

  return 0;
}


Measured memory_bytes: 256
/*Analysis Requires Calm*/
#include<bits/stdc++.h>
#define T int t; scanf("%d",&t); while(t--)
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORD(i,a,n) for(i=a;i>=n;i--)
#define FORS(i,a) for(i=0;a[i];i++)
#define si(x) scanf("%d",&x)
#define sc(x) cin>>x
#define sd(x) scanf("%lf",&x)
#define sll(x) scanf("%lld",&x)
#define ss(x) scanf("%s",x)
#define prs(x) printf("%d ",x)
#define pc(x) printf("%c",x)
#define pi(x) printf("%d\n",x)
#define pd(x) printf("%lf\n",x)
#define pll(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",x)
#define M 1000000007
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define pb push_back
#define fr first
#define se second
#define in insert
#define er erase
#define pii pair<int, int>
#define plll pair<long long, long long>
#define tr(container, it)  for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define INF 1ll<<60
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230
ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n&1) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n&1) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
using namespace std;

int main()
{
   int i,j;
   ll x;
   sll(x);
   ll y=x%11;
   ll ans=(x/11)*2;
   if(y>0)
      ans++;
   if(y>6)
      ans++;
   pll(ans);
   return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
long long calc(long long a, long long b, long long l, long long r) {
	if (a <= l && r <= b) {
		if (r - l >= 4) return 0;
		long long res = 0;
		for (long long i = l; i < r; ++i) {
			res ^= i;
		}
		return res;
	}
	if (r <= a || b <= l) return 0;
	long long lc = calc(a, b, l, (l + r) >> 1);
	long long rc = calc(a, b, (l + r) >> 1, r);
	return lc ^ rc;
}
int main() {
	long long A, B;
	cin >> A >> B;
	long long res = calc(A, B + 1, 0, 1LL << 60);
	cout << res << endl;
	return 0;
}

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

int main() {
    int x;
    cin >> x;
    int max1 = 0;
    if(x==1){
        cout << 1 << endl;
        return 0;
    }
    else{
        int sq = sqrt(x);
        for(int i=2;i<(sq+1);i++){
            int count = i;
            while(count<=x){
                if(max1<count) max1 = count;
                count *= i;
            }
        }
        cout << max1 << endl;
    }
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Hernan
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {

            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            int tmp = b;
            b = a;
            a = tmp;

            tmp = c;
            c = a;
            a = tmp;

            out.println(a + " " + b + " " + c);


        }

    }
}



Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int main(){
  int n;
  int x[25],y[25];
  while(1){
    cin >> n;
    if(n==0){
      break;
    }
    for(int i=0;i<n;i++){
      cin >> x[i] >> y[i];
    }
    int a[25]={0};
    int min=10000;
    int b=-1;
    int count=0;
    int ans=1;
    for(int i=0;i<n;i++){
      min = 10000;
      b=-1;
      for(int j=0;j<n;j++){
        if(y[j]<min&&a[j]==0){
          b=j;
          min=y[j];
        }
      }
      if(count+x[b]>y[b]){
        ans=0;
        break;
      }
      count+=x[b];
      a[b]=1;
    }
    if(ans==0){
      cout << "No" << endl;
    }else{
      cout<< "Yes" << endl;
    }
  }
}

Measured memory_bytes: 2988
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <sstream>
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[])
{
    ll n, a, b;
    std::cin >> n >> a >> b;
    if (a > b)
    {
        std::cout << 0 << std::endl;
        return 0;
    }
    if (n == 1){
        if (a == b) {
        std::cout << 1 << std::endl;
        } else {
            std::cout << 0 << std::endl;
        }
        return 0;
    }
    ll ans = (b - a) * (n - 2) + 1;
    std::cout << ans << std::endl;
    return 0;
}

Measured memory_bytes: 256
private fun readLn() = readLine()!!
private fun readStrings() = readLn().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() }
private fun readDouble() = readLn().toDouble()
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main(args: Array<String>) {
    val n=readInt()
    if(n>=400&&n<=599){
        println(8)
    }else if(n>=600&&n<=799){
        println(7)
    }
    else if(n>=800&&n<=999){
        println(6)
    }else if(n>=1000&&n<=1199){
        println(5)
    }else if(n>=600&&n<=1399){
        println(4)
    }else if(n>=1400&&n<=1599){
        println(3)
    }
    else if(n>=1600&&n<=1799){
        println(2)
    }else if(n>=1800&&n<=1999){
        println(1)
    }
}

Measured memory_bytes: 34540
using System;
using System.Linq;
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] b = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                if (i == 0) { a[i] = b[i]; continue; }
                if (i == n - 1) { a[i] = b[i - 1]; continue; }
                a[i] = Math.Min(b[i - 1], b[i]);
            }

            Console.WriteLine(a.Sum());
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
long long i, j, k;
long long H, W;
string s[2000];
bool bad[2001][2001];
long long l[2001];
long long width[2001];
long long top[2001];
long long bottom[2001];

int main(){
    cin >> H >> W;
    for(i=0; i<H; i++){
        cin >> s[i];
    }
    for(i=1; i<H; i++){
        for(j=0; j<W; j++){
            bad[i][j] = (s[i-1][j-1] == '#') ^ (s[i][j-1] == '#') ^ (s[i-1][j] == '#') ^ (s[i][j] == '#');
        }
    }
    long long ans = 0;
    long long r;
    for(r=1; r<=W; r++){
        vector<long long> stack = {};
        for(i=0; i<=H; i++){
            if(bad[i][r-1]){
                l[i] = r - 1;
            }
            width[i] = r - l[i];
            while(stack.size() > 0 && width[stack[stack.size()-1]] >= width[i]){
                stack.pop_back();
            }
            top[i] = stack.size() == 0 ? 0 : stack[stack.size()-1];
            stack.push_back(i);
        }
        stack.resize(0);
        for(i=H; i>=0; i--){
            while(stack.size() > 0 && width[stack[stack.size()-1]] >= width[i]){
                stack.pop_back();
            }
            bottom[i] = stack.size() == 0 ? H : stack[stack.size()-1];
            stack.push_back(i);
        }
        for(i=0; i<=H; i++){
            ans = max(ans, width[i] * (bottom[i] - top[i]));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8320
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
    vector<long long> A(100001, 0);
    vector<long long> result;
    int N, Q;
    long long sum = 0;
    cin >> N;

    for (int i = 0; i < N; i++){
        long long a;
        cin >> a;
        A[a] += 1;
        sum += a;
    }
    cin >> Q;
    result.resize(Q, 0);
    for (int i = 0; i < Q; i++){
        long long b, c;
        cin >> b >> c;
        long long tmp = A[b];
        A[b] = 0;
        A[c] += tmp;
        sum -= (b * tmp);
        sum += (c * tmp);
        result[i] = sum;
    }
    for (int i = 0; i < Q; i++){
        cout << result[i] << endl;
    }
}   


Measured memory_bytes: 4780
S = input()[::-1]
N = len(S)

prev = "_"
i = 0
ans = 0
while i < N:
    if S[i] == prev:
        if i == N-1:
            break
        prev = S[i:i+2]
        ans += 1
        i += 2
    else:
        ans += 1
        prev = S[i]
        i += 1
print(ans)

Measured memory_bytes: 41968
#include <iostream>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>
#include <utility>
#include <cassert>
#include <algorithm>
#include <cstring>

using namespace std;

int main(int argc, char *argv[]) {
  int N;
  vector<int64_t> list;
  vector<pair<int64_t, int64_t>> solution;
  cin >> N;
  list.reserve(N);
  solution.reserve(N);
  for(int i = 0; i < N; i++){
    int64_t x;
    cin >> x;
    list.push_back(x);
  }
  sort(list.begin(), list.end());
  int64_t max_val = *list.rbegin();
  int i = 1;
  for(; i < N - 1 && list[i] < 0; i++){
    solution.push_back({max_val, list[i]});
    max_val -= list[i];
  }
  for(; i < N - 1 && list[i] == 0; i++){
    solution.push_back({max_val, list[i]});
    max_val -= list[i];
  }
  int64_t min_val = *list.begin();
  for(; i < N - 1; i++){
    solution.push_back({min_val, list[i]});
    min_val -= list[i];
  }
  solution.push_back({max_val, min_val});
  cout << (max_val - min_val) << endl;
  for(auto &e : solution) cout << e.first << " " << e.second << endl;
  return 0;
}


Measured memory_bytes: 4224
const int mod=1e9+7;
#include <bits/stdc++.h>
using namespace std;
bool isSafe(int x,int y,int m,int n)
{
    if(x>=0&& x<m && y>=0 && y<n)
    return true;
    return false;
}


long long util(const vector<vector<char>> & grid ,vector<vector<long long>> & dp,int x,int y,int m,int n)
{
    if(isSafe(x,y,m,n))
    {
        
        
        if(x==m-1 && y==n-1)
        return 1;
        if(grid[x][y]=='#')
        return 0;
        
        
        
        if(dp[x][y]!=-1)
        return dp[x][y]%mod;
        
        dp[x][y]=((util(grid,dp,x+1,y,m,n)%mod)+(util(grid,dp,x,y+1,m,n)%mod)%mod);
        
        return dp[x][y]%mod;
    }
    
    return 0;
}


int main() {
        int m;
        cin>>m;
        int n;
        cin>>n;
    vector<vector<char>> grid(m,vector<char>(n));
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<n;j++)
       cin>>grid[i][j];
    }
     vector<vector<long long>> dp(m,vector<long long>(n,-1));
     
     cout<<util(grid,dp,0,0,m,n);
    
	return 0;
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef unsigned long long ll;
int N, n, M, K;


int main(){
    cin >> N >> K;
    string s;
    cin >> s;
    s[K-1] = tolower(s[K-1]);
    cout << s;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main(void) {

	int k;
	string s;

	cin >> k >> s;

	if (k >= s.length()) {

		cout << s;

	}
	else {

		for (int i = 0; i < k; i++) {

			cout << s[i];

		}

		cout << "...";

	}

	

}

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

public class Main {

	private static final char UP = 'U';
	private static final char DOWN = 'D';
	private static final char LEFT = 'L';
	private static final char RIGHT = 'R';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int sx = scanner.nextInt(), sy = scanner.nextInt(), tx = scanner.nextInt(), ty = scanner.nextInt();
			int x = tx - sx, y = ty - sy;
			StringBuilder sb = new StringBuilder();
			IntStream.range(0, y).forEach(i -> sb.append(UP));
			IntStream.range(0, x).forEach(i -> sb.append(RIGHT));
			IntStream.range(0, y).forEach(i -> sb.append(DOWN));
			IntStream.range(0, x).forEach(i -> sb.append(LEFT));
			sb.append(LEFT);
			IntStream.range(0, y + 1).forEach(i -> sb.append(UP));
			IntStream.range(0, x + 1).forEach(i -> sb.append(RIGHT));
			sb.append(DOWN);
			sb.append(RIGHT);
			IntStream.range(0, y + 1).forEach(i -> sb.append(DOWN));
			IntStream.range(0, x + 1).forEach(i -> sb.append(LEFT));
			sb.append(UP);
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 36136
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

vector< pair<int, pair<int, int> > > points;
 
signed main() {
    int N; cin >> N;
    for(int i=0; i<N; i++) {
        int x, y; cin >> x >> y;
        points.push_back(make_pair(x, make_pair(y, 1)));
    }
    for(int i=0; i<N; i++) {
        int x, y; cin >> x >> y;
        points.push_back(make_pair(x, make_pair(y, 0)));
    }
    sort(points.begin(), points.end());

    int ans = 0;
    set<int> S;
    for(int i=0; i<2*N; i++) {
        if(points[i].second.second == 1) {
            // red point
            S.insert(points[i].second.first);
        }
        else {
            // blue point
            auto it = S.lower_bound(points[i].second.first);
            if(it == S.begin()) continue;
            it--;
            ans++;
            S.erase(*it);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 

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

	vector<int> ans(4, 0);
	for(int i=0; i<N; i++){
		if(S[i] == "AC") ans[0]++;
		else if(S[i] == "WA") ans[1]++;
		else if(S[i] == "TLE") ans[2]++;
		else if(S[i] == "RE") ans[3]++;
	}

	cout << "AC x " << ans[0] << endl;
	cout << "WA x " << ans[1] << endl;
	cout << "TLE x " << ans[2] << endl;
	cout << "RE x " << ans[3] << endl;
	return 0;


}


Measured memory_bytes: 6360
n = int(input())
x = list(map(int, input().split()))
left = 0
right = 0
for i in x:
    right += i
reco = []
i = 0
while right > left:
    left += x[i]
    right -= x[i]
    i += 1
    reco.append(right - left)
reco[-1] = 0-reco[-1]
print(min(reco))


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

typedef long long ll;

const int N = 2e5;
const ll INF = 1e18;

int n;
ll k;

vector<ll> pos, neg;

ll cek(ll x){
	ll id = 0ll;
	if(x >= 0){
		id += (ll)(pos.size()) * (ll)(neg.size());
		int r = pos.size()-1;
		for(int i=0;i<pos.size();i++){
			while(r >= 0 &&pos[i] * pos[r] > x) r--;
			if(r-i <= 0) break;
			id+=(ll)(r-i);
		}
		r = 0;
		for(int i=neg.size()-1;i>=0;i--){
			while(r < neg.size() && neg[i] * neg[r] > x) r++;
			if(i-r <= 0) break;
			id+=(ll)(i-r);
		}
	} else {
		int r = neg.size()-1;
		for(int i=pos.size()-1;i>=0;i--){
			while(r >= 0 && pos[i] * neg[r] > x) r--;
			id+=(ll)(r+1);
		}
		/*
		3 3
		-4 -2
		*/
	}
	return id;
}

int main(){
	scanf("%d %lld",&n,&k);
	for(int i=1;i<=n;i++){
		ll x;
		scanf("%lld",&x);
		if(x >= 0) pos.push_back(x);
		else neg.push_back(x);
	}
	sort(pos.begin(),pos.end());
	sort(neg.begin(),neg.end());
	ll l = -INF;
	ll r = INF;
	ll ans = INF;
	while(l<=r){
		ll mid = (l+r)/2;
		ll idx = cek(mid);
		if(idx >= k){
			ans = mid;
			r = mid-1;
		} else {
			l = mid+1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 40;

int p[10], pre1, pre2;

bool dfs(int pos) {
    if (pos >= 10) return true;
    int tmp1 = pre1, tmp2 = pre2;

    if (p[pos] > pre1) {
        pre1 = p[pos];
        if (dfs(pos + 1)) return true;
        pre1 = tmp1;
    }

    if (p[pos] > pre2) {
        pre2 = p[pos];
        if (dfs(pos + 1)) return true;
        pre2 = tmp2;
    }

    return false;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    int T;
    cin >> T;
    for (int t = 0; t < T; t++) {
        for (int i = 0; i < 10; i++) cin >> p[i];
        pre1 = pre2 = -1;
        if (dfs(0)) cout << "YES\n";
        else cout << "NO\n";
    }
}



Measured memory_bytes: 3144
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

    int n, gokei;
    cin >> n >> gokei;

    int sum;


    for (int i = 0; i <= n; i++) {
        for (int j = 0; (i + j) <= n; j++) {
            //for (int k = 0; (i + j + k) <= n; k++) {
                sum = 10000 * i + 5000 * j + 1000 * (n-i-j);

                if (sum == gokei) {
                    cout << i << ' ' << j << ' ' << (n-i-j) << endl;
                    return 0;
                }
            //}
        }
    }

    cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, k; scanf("%d%d", &n, &k); std::vector<int> a(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	
	std::vector<int> dp(n, 1 << 30); dp[0] = 0;
	for(int i = 0; i < n; i++) {
		for(int j = std::max(0, i - k); j < i; j++) {
			dp[i] = std::min(dp[i], dp[j] + std::abs(a[j] - a[i]));
		}
	}
	printf("%d\n", dp[n - 1]);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <utility>
#include <string>
#include <math.h>
#include <algorithm>
#include <cstring>
#include <cctype>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
typedef long long int lli;

using namespace std;

int main() {
   
   int N;
   cin >> N;
   int ot;
   for(int i=0;i<100;i++){
       if(i*1000-N>=0){
           ot=i*1000-N;
           break;
       }
   }
    cout << ot << endl;
}

Measured memory_bytes: 3632
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=11;
string s;
int mask,n;
ll ans;

ll calc(){
	ll cur=0,sum=0;
	rep(i,n){
		cur=cur*10LL+(int)(s[i]-'0');
		if(mask&(1<<i))sum+=cur,cur=0;
	}
	sum+=cur;
	return sum;
}

int main(){
	cin>>s;
	n=s.size();
	for(mask=0;mask<(1<<(n-1));mask++)
	ans+=calc();
	cout<<ans;
	return 0;
}

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

int main(){
  int h,w,K;
  cin>>h>>w>>K;
  vector<string> c(h);
  rep(i,h) cin>>c[i];
  int ans=2000;
  
  rep(bit,1<<(h-1)){
    int res=0;
    vector<int> yoko;
    yoko.pb(0);
    rep(j,h-1){
      if(1&bit>>j){
        yoko.pb(j+1);
        res++;
      }
    }
    yoko.pb(h);
    if(ans<res) continue;
    
    vector<int> nanko(yoko.size()-1);
    int judge=0;
    bool flag=false;
    rep(i,w){
      rep(j,yoko.size()-1){
        for(int k=yoko[j];k<yoko[j+1];k++){
          if(c[k][i]=='1') nanko[j]++;
        }
      }
      rep(j,nanko.size()){
        if(nanko[j]>K){
          rep(k,nanko.size()) nanko[k]=0;    
          if(judge==0){
            flag=true;
            break;            
          }
          res++;     
          i--;
          judge=0;
          break;
        }
        if(j==nanko.size()-1) judge++;
      }
      if(flag) break;
    }
    if(judge) ans=min(ans,res);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3644