akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

void display(pair<int, char> c[], int n) {
  rep(i, 0, n) {
    if (i > 0)
      cout << " ";
    cout << c[i].second << c[i].first;
  }
  cout << endl;
}

void bubble_sort(pair<int, char> c[], int n) {
  rep(i, 0, n) {
    repr(j, 1, n) {
      if (c[j].first < c[j - 1].first)
        swap(c[j], c[j - 1]);
    }
  }
  display(c, n);
}

void selection_sort(pair<int, char> c[], int n) {
  rep(i, 0, n) {
    int minj = i;
    rep(j, i, n) {
      if (c[j].first < c[minj].first)
        minj = j;
    }
    if (c[i].first > c[minj].first)
      swap(c[i], c[minj]);
  }
  display(c, n);
}

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

  int n;
  cin >> n;
  pair<int, char> p1[n], p2[n];
  rep(i, 0, n) {
    string s;
    cin >> s;
    p1[i] = make_pair(s[1] - '0', s[0]);
    p2[i] = p1[i];
  }
  bubble_sort(p1, n);
  cout << "Stable" << endl;
  selection_sort(p2, n);
  rep(i, 0, n) {
    if (p1[i] != p2[i]) {
      cout << "Not stable" << endl;
      return 0;
    }
  }
  cout << "Stable" << endl;
}



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

int main(){

    string s;
    cin >> s;
    s = "#" + s;

    for(char c = 'a'; c <= 'z'; c++){
        ll mnV = 101010;
        ll mnIdx = 101010;
        vector<ll>tmp(101010, 0);
        for(ll i = 1; i < s.size(); i++){
            if(s[i] == c)tmp[i] = tmp[i - 1] + 1;
            else tmp[i] = tmp[i - 1] - 1;
            if(mnV < tmp[i]){
                cout << mnIdx << " " << i << endl;
                return 0;
            }
            if(mnV > tmp[i - 1]){
                mnV = tmp[i - 1];
                mnIdx = i;
            }
        }
    }

    cout << "-1 -1" << std::endl;
    
    return 0;
}


Measured memory_bytes: 1276
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n){cin>>a[i];}
    Sort(a);
    cout<<abs(a[n-1]-a[0])<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    string a, b, c; cin >> a >> b >> c;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) ;
        else if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i]) ans++;
        else ans += 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  string s;
  in(s);
  rep(i, s.size()){
    if(s[i] != '?')
      out(s[i]);
    else
      out('D');
  }
  memi;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
char g;
char f[4][13],a,pp;
int v[4][13],tt[100];
main(){
    tt['T']=10;tt['J']=11;tt['Q']=12;tt['K']=13;tt['A']=14;
    while(scanf("%c%c",&g,&pp),g!='#'){
        for(int i=0;i<4;i++)
            for(int j=0;j<13;j++){
                scanf("%c%c%c",&a,&f[i][j],&pp);
                if(a>='0'&&a<='9')v[i][j]=a-'0';
                else v[i][j]=tt[(int)a];
            }
        int lead=0,score[2]={};
        for(int i=0;i<13;i++){
            int w=-1,ws=-1;
            for(int j=0;j<4;j++){
                int sc=v[j][i];
                if(f[j][i]==g)sc+=100;
                if(f[j][i]!=g&&f[j][i]!=f[lead][i])continue;
                if(sc>ws)ws=sc,w=j;
            }
            lead=w;
            score[w%2]++;
        }
        if(score[0]>score[1])cout<<"NS "<<score[0]-6<<endl;
        else cout<<"EW "<<score[1]-6<<endl;
    }
}

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

int main() {
	int n, ans = 0;
	cin >> n;
	vector<int> p(n);
	for (int& i : p) cin >> i;
	for (int i = 1; i < n - 1; ++i) {
		if (p[i - 1] < p[i] && p[i] < p[1 + i] || p[i - 1] > p[i] && p[i] > p[1 + i]) ++ans;
	}
	cout << ans;
}

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

using namespace std;

string a;
int main() {
  cin >> a;
  int cnt = 0;
  for (int i = 0; i < 3; i++)
    if (a[i] == 'o') cnt++;
  
  cout << 700 + cnt * 100;
  return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

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

const double PI = 3.14159265358979;

void solve()
{
  int n, m, a, b;
  cin >> n >> m;

  vector< vector<ll> > G(n, vector<ll>(0));
  for(int i = 0; i < m; ++i)
  {
    cin >> a >> b;
    a--; b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }

  vector<bool> visited(n, false);
  queue<P> que;

  que.push(P(0, 0));

  while(!que.empty())
  {
    P fr = que.front();
    que.pop();
    ll now = fr.first;
    ll depth = fr.second;

    if (depth >= 3) break;

    if (visited[now]) continue;
    visited[now] = true;

    for(const auto& next : G[now])
    {
      que.push(P(next, depth + 1));
    }
  }

  cout << (visited[n - 1] ? "POSSIBLE" : "IMPOSSIBLE");  
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

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

#define fr first
#define sc second

int main(){
	static ll n,m;
	static ll a[100010],b[100010],c[100010];
	scanf("%lld%lld",&n,&m);
	for(int i = 1 ; i <= n ; i ++){
		scanf("%lld",&a[i]);
	}
	for(int i = 1 ; i <= m ; i ++){
		scanf("%lld%lld",&b[i],&c[i]);
	}
	
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	vector<P> vec;
	for(int i = 1 ; i <= m ; i ++){
		vec.push_back(P(c[i],b[i]));
	}
	sort(vec.rbegin(),vec.rend());
	
	int s = 1, t = 0;
	ll sum = 0;
	ll cnt = 0;
	while(cnt < n){
		if(t < vec.size() && a[s] < vec[t].fr){
			sum += vec[t].fr;
			vec[t].sc--;
			if(vec[t].sc == 0)t ++;
		}
		else {
			sum += a[s];
			s ++;
		}
		cnt ++;
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 4724
n, x, d = map(int, input().split())

if d == 0:
  if x == 0:
    print(1)
    exit()
  else:
    print(n + 1)
    exit()
if d < 0:
  y = x
  x = x + d * (n - 1)
  d = -d
else:
  y = x + d * (n - 1)
  
U = {}
ans = 0
has0 = 0
for k in range(1, n + 1):
  r = (x * k) % d
  s = k * d * (k - 1) // 2
  v1 = k * x + s
  v2 = k * y - s
  if r in U:
    u = U[r]
    if v1 > u[1] or v2 < u[0]:
      ans += (u[1] - u[0]) // d + 1
    else:
      v1 = min(v1, U[r][0])
      v2 = max(v2, U[r][1])
  U[r] = (v1, v2)
  if r == 0 and v1 <= 0 and v2 >= 0:
    has0 = 1
#  print(ans, k, v1, v2, U)

for r, u in U.items():
  ans += (u[1] - u[0]) // d + 1

if not has0: ans += 1
  
print(ans)

Measured memory_bytes: 102732
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define vin(v, N) vi v; rep(i, N) {int x; cin >> x; v.push_back(x);}

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)

const int MAX_N = 1e5 + 5;

void solve() {
    int N;
    cin >> N;
    vin(A, 2*N);
    REP(i, 0, N-3) {
        if (A[i*2] == A[i*2+1] && A[i*2+2] == A[i*2+3] && A[i*2+4] == A[i*2+5]) {
            cout << "Yes";
            return;
        }
    }
    cout << "No";
}

//#define LOCAL 1

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

#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    solve();

    return 0;
}


Measured memory_bytes: 3576
#include<iostream>

using namespace std;

int sep(int a, int b)
{
	int num[6];
	int i,j,count;
	int k = 0;
	for(i=a; i<=b; i++){
		count = 0;
		j = i;
		while(j > 0){
			num[count] = j % 10;
			j /= 10;
			count++;
		}
		if(num[0] == num[4] && num[1] == num[3])
			k++;
	}
	return k;
}

int main()
{
	int a,b;
	cin >> a >> b;
	cout << sep(a,b) << endl;
} 



Measured memory_bytes: 256
#include<iostream>

using namespace std;

string t, h;
int main(){
    int sc1 = 0, sc2 = 0;
    int n;
    cin >> n;
    while(n--){
        cin >> t >> h;
        if (t == h) { ++sc1; ++sc2; }
        else if(t > h) sc1 += 3;
        else sc2 += 3;
    }
    cout << sc1 << " " << sc2 << endl;
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>

using namespace std;

int main(){

    string s[3];
    cin>> s[0]>> s[1]>> s[2];

    int turn=0;
    while(1){
        if(s[turn].empty()){
            cout<< (char)('A'+turn)<< endl;
            return 0;
        }
        int next=s[turn].front()-'a';
        s[turn]=s[turn].substr(1);
        turn=next;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;
typedef long long ll;


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

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

    ll sum =0;

    for (int i =A ; i<=T; i++){
        if (i % A ==0)
            sum += B;
    }
    cout << sum;
}

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

using namespace std;

const int maxx = 505;

int n, m;
char t[maxx][maxx], tb[maxx][maxx], tr[maxx][maxx];

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) tb[i][j] = tr[i][j] = '.';
	for(int i = 0; i < n; i+=2) for(int j = 0; j < m; j++) tb[i][j] = '#';
	for(int i = 1; i < n; i+=2) for(int j = 0; j < m; j++) tr[i][j] = '#';
	for(int i = 0; i < n; i++) tb[i][0] = tr[i][m-1] = '#', tb[i][m-1] = tr[i][0] = '.';
	for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) { cin >> t[i][j]; if (t[i][j] == '#') tb[i][j] = tr[i][j] = t[i][j]; }
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
			cout << tr[i][j];
		cout << endl;
	} 
	cout << endl;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < m; j++)
			cout << tb[i][j];
		cout << endl;
	} 
	return 0;
}

Measured memory_bytes: 1536
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll a, b, c, k;
    std::cin >> a >> b >> c >> k;
    ll l1[] = { 1, 0, -1, };
    ll l2[] = { a, b, c, };
    ll ans = 0;
    for (ll i = 0; i < 3; i++) {
        ll s = std::min(k, l2[i]);
        ans += s * l1[i];
        k -= s;
    }
    std::cout << ans << "\n";
    return 0;
}


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

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

    string res = "No";
    long long sum = 0;
    for (int i = 0; i < n.size(); i++) {
        sum += (n.at(i) - '0');
    }

    if (sum % 9 == 0) res = "Yes";

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt(); val m = sc.nextInt()
  val graph = new Array[List[(Int, Int)]](n + 1)
  for(i <- 0 to n)
    graph(i) = List()

  for(i <- 1 to m){
    val a = sc.nextInt(); val b = sc.nextInt(); val c = sc.nextInt()
    graph(a) = (b, c) :: graph(a)
  }


  // main process
  var tmp = 0L
  var flag = false
  val dp: Array[Long] = Array.fill(n+1)(-1e18.toLong)
  dp(1) = 0

  for(i <- 1 to 2 * (n-1)) {
    for(a <- 1 to n) {
      for((b, c) <- graph(a)){
        dp(b) = Math.max(dp(b), dp(a) + c)
      }
    }

    if(i == n-1)
      tmp = dp(n)
    else if(i == 2 * (n-1) && tmp < dp(n))
      flag = true
  }
  

  if(flag)
    println("inf")
  else
    println(dp(n))
}


Measured memory_bytes: 66076
a = int(input())+1
b = int(input())+1
c = int(input())+1
x = int(input())

counter = 0

for _a in range(a):
    for _b in range(b):
        for _c in range(c):
            ans = 500*_a + 100*_b + 50*_c
            if ans == x:
                counter += 1

print(counter)

Measured memory_bytes: 39664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod=1e9+7;

int main(){
    int x, y;
    cin >> x >> y;
    
    int money=0;
    if(x==1)money+=300000;
    else if(x==2) money+=200000;
    else if(x==3) money+=100000;
    if(y==1)money+=300000;
    else if(y==2) money+=200000;
    else if(y==3) money+=100000;

    if(x==1&&y==1)money+=400000;
    
    cout << money;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(Scanner sc = new Scanner(System.in)){
			final long N = sc.nextLong();
			final long K = sc.nextLong();
			
			if(K == 0){
				System.out.println(N * N);
				return;
			}
			
			long answer = 0;
			for(long B = K + 1; B <= N; B++){
				final long one_step = B - K;
				final long limit = N / B;
				
				//System.out.println(B + " " + one_step + " " + limit);
				answer += one_step * limit;
				
				//System.out.println((limit * B + K) + " " + (N - 1));
				answer += Math.max(0, (N + 1) - (limit * B + K)); 
				
				//System.out.println(answer);
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i=0; i<n; i++) cin >> s[i];
	for(int i=0; i<n; i++) sort(s[i].begin(), s[i].end());

	map<string, long long> cnt_map;
	long sum = 0;
  for(int i=0; i<n; i++) cnt_map[s[i]]++;
	// for(int i=0; i<cnt_map.size(); i++) sum += cnt_map[s[i]]*(cnt_map[s[i]]-1) / 2;
	for(auto itr = cnt_map.begin(); itr != cnt_map.end(); itr++){
		 sum += (itr->second*(itr->second-1) / 2);
		//  sum += static_cast<long long>(itr->second*(itr->second-1) / 2);
  }

	// cout << "--sorting result--" << endl;
	// for(int i=0; i<n; i++) cout << s[i] << endl;
	cout << sum << endl;
};

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    int x,a,b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
L.insert(0,0)
ans = 0
for i in range(1,N+1):
  k = L[i]
  flag = True
  for j in range(i):
    if k >= L[j]:
      None
    else:
      flag = False
      break
  if flag:
    ans += 1
print(ans)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
from fractions import gcd
from functools import reduce
def lcm(x,y):
  return (x*y)//gcd(x,y)
mod = 10**9+7
l = reduce(lcm, a) % mod
ans = 0
for i in range(n):
  ans += l * pow(a[i], mod - 2, mod)
  ans %= mod
print(ans)

Measured memory_bytes: 5608
S = [input() for _ in range(3)]
ABC = ['a', 'b', 'c']

i = 0
while True:
  if len(S[i]) == 0:
    print(ABC[i].upper())
    break
  tmp = S[i][0]
  S[i] = S[i][1:]
  i = ABC.index(tmp)


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 100;
int a, b;
char ans[N][N];
// h, w <= 100
int main() {
    cin >> a >> b;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (j < 50)
                ans[i][j] = '.';
            else
                ans[i][j] = '#';
        }
    }
    a--; b--;
    if (a) {
        for (int i = 0; i < N; i += 2) {
            for (int j = 51; j < N; j += 2) {
                ans[i][j] = '.';
                --a;
                if (!a)
                    break;
            }
            if (!a)
                break;
        }
    }
    if (b) {
        for (int i = 0; i < N; i += 2) {
            for (int j = 0; j < 50; j += 2) {
                ans[i][j] = '#';
                --b;
                if (!b)
                    break;
            }
            if (!b)
                break;
        }
    }
    cout << N << ' ' << N << endl;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
 
using namespace std ;
 
typedef double D ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned int ui ;
typedef unsigned long long ull ;
 
# define F first
# define S second
# define R return
# define C continue 
# define pb push_back 
# define pf push_front
# define mp make_pair
 
# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp
 
# define vi vector <int>
# define vb vector <bool>
# define vll vector <ll>
# define vs vector <string>
 
# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >
 
# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >
 
# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >
# define vvpii vector < vector < pii > >
 
# define Fi(i,L,R) for (int i = L ; i <= R ; i++)
# define Fd(i,R,L) for (int i = R ; i >= L ; i--)
# define fast ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
 
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))
 
const ld PI = 3.1415926535897932384626 ;
const ll MOD = 1e9 + 7 ;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve ()
{
  string s ;
  cin >> s ;
  if (s[2] == s[3] && s[4] == s[5])
     cout << "Yes" ;
  else
    cout << "No" ;
}
 
int main()
{
	//freopen ("input.txt","r",stdin) ;
	//freopen ("output.txt","w",stdout) ;
	fast ;
	int t = 1 ;
//	cin>>t ;
	while (t--) 
	  solve () ;
	return 0 ;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[10101];
ll B[10101];

bool isprime(ll v) {
	for(ll i=2;i*i<=v;i++) if(v%i==0) return false;
	return (v!=1);
}



void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	j=0;
	int g=0;
	N++;
	FOR(i,N) {
		cin>>A[i];
		g=__gcd(g,abs(A[i]));
	}
	
	reverse(A,A+N);
	
	set<int> cand;
	
	for(i=1;i*i<=g;i++) {
		if(g%i==0) {
			cand.insert(i);
			cand.insert(g/i);
		}
	}
	for(i=2;i<=20005;i++) cand.insert(i);
	
	
	FORR(c,cand) if(isprime(c) && A[0]%c==0) {
		ZERO(B);
		FOR(i,N) B[i%(c-1)]+=A[i];
		FOR(i,N) if(B[i%(c-1)]%c) break;
		if(i==N) cout<<c<<endl;
	}
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);

int main() {
  ll N, Q;
  cin >> N >> Q;

  vvi G(N);

  for (ll i = 0; i < N - 1; i++) {
    ll a, b;
    cin >> a >> b;
    a -= 1;
    b -= 1;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  vi parent(N);
  vvi children(N);
  {
    vi visited(N);
    queue<ll> q;
    q.push(0);
    visited[0] = 1;
    while (q.size()) {
      ll fr = q.front();
      q.pop();
      for (ll to : G[fr]) {
        if (visited[to] == 0) {
          parent[to] = fr;
          visited[to] = 1;
          children[fr].push_back(to);
          q.push(to);
        }
      }
    }
  }

  vi cnt(N);

  for (ll i = 0; i < Q; i++) {
    ll p, x;
    cin >> p >> x;
    p -= 1;
    cnt[p] += x;
  }

  queue<ll> q;
  q.push(0);
  while (q.size()) {
    ll fr = q.front();
    q.pop();
    for (ll to : children[fr]) {
      cnt[to] += cnt[fr];
      q.push(to);
    }
  }

  for (ll i = 0; i < N; i++) {
    cout << cnt[i];
    if (i == N - 1)
      cout << endl;
    else
      cout << ' ';
  }
}

Measured memory_bytes: 27492
#include<iostream>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    ll N, M;
    cin >> N >> M;
    ll db=2;
    for(int i=1; i<M; i++) db=db*2;
    ll ans = (1900*M+100*(N-M))*db;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(200000)
from collections import deque


def read():
    N, Q = list(map(int, input().strip().split()))
    G = [list() for i in range(N+1)]
    PX = list()
    for i in range(N-1):
        a, b = list(map(int, input().strip().split()))
        G[a].append(b)
        G[b].append(a)
    for i in range(Q):
        px = list(map(int, input().strip().split()))
        PX.append(px)
    return N, Q, G, PX


def bfs(parent, G, C, V):
    q = deque()
    q.append(1)
    while len(q) > 0:
        parent = q.pop()
        V[parent] = True
        for child in G[parent]:
            if not V[child]:
                C[child] += C[parent]
                q.append(child)
    

def solve(N, Q, G, PX):
    C = [0 for i in range(N+1)]
    V = [False for i in range(N+1)]
    for p, x in PX:
        C[p] += x
    bfs(1, G, C, V)
    return ' '.join(map(str, C[1:]))
    

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 124344
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin>>n;
	int x,y,z;
	x=y=z=0;
	for(int i = 0; i < n; i++)
	{
		int m;
		cin>>m;
		if(m%4==0)
		x++;
		else if(m%2==0)
		y++;
		else
		z++;
	}
	if(z<=x||(z==x+1&&y==0))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0; 
}

Measured memory_bytes: 256
n = int(input())

num_e = 1
num = num_e**2 + num_e

l = []


ok = 0

while num//2 <= 10**5:
    if num // 2 == n:
        ok = 1
        break

    num_e += 1
    num = num_e**2 + num_e

if not ok:
    print('No')
else:
    print('Yes')
    ans = [[num_e] for i in range(num_e+1)]

    num = 1
    for i in range(num_e):
        for j in range(i+1):
            ans[j].append(num)
            ans[i+1].append(num)
            num += 1
    print(num_e+1)
    for i in range(num_e+1):
        print(' '.join(map(str, ans[i])))


Measured memory_bytes: 9064
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int i, p, j, set, pmin = 0, jmin = 0;
		for(i = 0; i < 3; i++) {
			p = sc.nextInt();
			if(i == 0 || pmin > p) pmin = p;
		}
		for(i = 0; i < 2; i ++) {
			j = sc.nextInt();
			if(i == 0 || jmin > j) jmin = j;
		}
		set = pmin + jmin - 50;
		System.out.println(set);
	}
}

Measured memory_bytes: 17356
n,k=map(int,input().split())
l=list(input())
s=l[0]
m=0
c=1
for i in range(1,n):
  if l[i]!=s:
    c+=1
    s=l[i]
if c//2<=k:
  print(n-1)
else:
  for i in range(1,n-1):
    if l[i]=="R":
      if l[i+1]=="R":
        m+=1
    if l[i]=="L":
      if l[i-1]=="L":
        m+=1
  if l[0]=="R" and l[0]==l[1]:
    m+=1
  if l[-1]=="L" and l[-2]==l[-1]:
    m+=1
  print(m+k*2)

Measured memory_bytes: 4084
s=input()
n=len(s)
ans=0
if n % 2 == 0:
  for i in range(int(len(s)/2)):
    if s[i] != s[n-i-1]:
      ans += 1
else:
  for i in range(int((len(s)-1)/2)):
    if s[i] != s[n-i-1]:
      ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define p pair<int,int>
#define P pair<int,p>
#define int long long
using namespace std;

P k[100000];
int ans;
signed main(){
int n;cin>>n;
for(int i=0;i<n;i++){
int a,b;cin>>a>>b;
k[i]={-a-b,{a,b}};
}
sort(k,k+n);
for(int i=0;i<n;i++){
if(i&1)ans-=k[i].second.second;
else ans+=k[i].second.first;
}
cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
 
using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;

int main(void) {
    Int t, x;
    cin >> t >> x;
    double result = (double)t / (double)x;
    cout << fixed << setprecision(10) << result << endl;
    return 0;
}



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

#define ll long long

using namespace std;
const int MX = 2'000 + 5; // check bounds!

int n, a[MX];
ll sol;

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

    for (int i = 0; i < n; ++i)
        for (int j = i + 1; j < n; ++j) {
            int dif = abs(a[i] - a[j]);
            auto l = lower_bound(a, a + n, dif + 1);
            auto r = lower_bound(a, a + n, a[i] + a[j]);
            if (l == a + n)
                continue;
            int x = r - l;
            if (l <= a + i && a + i < r)
                x--;
            if (l <= a + j && a + j < r)
                x--;
            sol += x;
        }
    cout << sol / 3;
    return 0;
}


Measured memory_bytes: 256
void main(){
	int n = _scan();
	writeln("ABC", n);
}

import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math;

// 1要素のみの入力
T _scan(T= int)(){
	return to!(T)( readln().chomp() );
}

// 1行に同一型の複数入力
T[] _scanln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split()){
		ln ~= elm.to!T();
	}
	return ln;
}


Measured memory_bytes: 2672
-- modules to import --

import Data.ByteString.Char8
import Data.Maybe
import Prelude

-- functions for this task --

read_Integer = fst . fromJust . Data.ByteString.Char8.readInteger
get_Integer  = read_Integer <$> Data.ByteString.Char8.getLine

calculate_digit_sum :: Integer -> Integer
calculate_digit_sum target
        | target >= 10 = val_mod + (calculate_digit_sum $ val_div)
        | target >=  0 = target
        where
                (val_div, val_mod) = divMod target 10

task_B :: Integer -> Bool
task_B target
        | mod target (calculate_digit_sum target) == 0 = True
        | otherwise                                    = False

-- main process is below --

main :: IO ()
main = do

        -- STEP.01
        -- read out the given integer
        integer_given <- get_Integer

        -- STEP.02
        -- output the answer of this task
        Prelude.putStrLn $ if (task_B $ integer_given) then "Yes" else "No"

-- End of this source code --

Measured memory_bytes: 380
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
ans=0
for _ in range(n):
    a=list(map(int,input().split()))
    sums=c
    for mm in range(m):
        sums+=b[mm]*a[mm]
    
    if sums>0:
        ans+=1
print(ans)
        


Measured memory_bytes: 3060
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

a,b,c,x,y = map(int,input().split())

#AとBのみ
cost1 = a*x + b*y
#ABのみ
cost2 = c*max(x,y)*2
#ABとA
cost3 = c*y*2 + abs(x - y)*a
#ABとB
cost4 = c*x*2 + abs(y-x)*b
ans = min(cost1,cost2)
ans = min(ans,cost3)
ans = min(ans,cost4)
print(ans)

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

using namespace std;

const int MAX = 100;
int a, b, c, d, e, f;

int main() {
  cin >> a >> b >> c >> d >> e >> f;
  long double ma = -1;
  int total = 0, sugar = 0;
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      for (int k = 0; k < MAX; k++) {
        for (int l = 0; l < MAX; l++) {
          const int sugarGram = k * c + l * d;
          const int waterGram = 100 * i * a + 100 * j * b;
          const int totalGram = waterGram + sugarGram;
          if (totalGram > f) {
            continue;
          }
          if ((waterGram / 100) * e < sugarGram) {
            continue;
          }
          const long double noudo = 100. * sugarGram / totalGram;
          if (ma < noudo) {
            ma = noudo;
            total = totalGram;
            sugar = sugarGram;
          }
        }
      }
    }
  }
  cout << total << " " << sugar << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(ll i=(x);i<(y);i++)
#define RREP(i,x,y) for(ll i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class ATwoCoins {
public:
    void solve(std::istream& in, std::ostream& out) {
        int A, B, C;
        in >> A >> B >> C;
        out << (A + B >= C ? "Yes" : "No") << "\n";
    }
};


signed main() {
    ATwoCoins solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>

class Point{
public:
    Point( double x, double y ) : x(x), y(y){}
    double x;
    double y;
    void Print(){
        std::cout << x << " " << y << "\n";
    }
};

void Koch( int n, const Point& p1, const Point& p2 ){
    if( n ){
        Point s( ( 2*p1.x + p2.x ) / 3, ( 2*p1.y + p2.y ) / 3 );
        Point t( ( p1.x + 2*p2.x ) / 3, ( p1.y + 2*p2.y ) / 3 );
        Point u( ( t.x - s.x )*cos( M_PI/3 ) - ( t.y - s.y )*sin( M_PI/3 ) + s.x,
                 ( t.x - s.x )*sin( M_PI/3 ) + ( t.y - s.y )*cos( M_PI/3 ) + s.y );
        
        // if( n == 1 ){
        //     s.x /= 3.0;
        //     s.y /= 3.0;
        //     t.x /= 3.0;
        //     t.y /= 3.0;
        //     u.x /= 3.0;
        //     u.y /= 3.0;
        // }

        Koch( n-1, p1, s );
        s.Print();
        Koch( n-1, s, u );
        u.Print();
        Koch( n-1, u, t );
        t.Print();
        Koch( n-1, t, p2 );
    }
    return;
}

int main(){
    int n;
    std::cin.tie(0);
    std::cin >> n;
    Point p1 = Point( 0.0, 0.0 );
    Point p2 = Point( 100.0, 0.0 );
    std::cout << std::fixed << std::setprecision(8);
    p1.Print();
    Koch( n, p1, p2 );
    p2.Print();
}


Measured memory_bytes: 3248
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int n,m,w,v;
ll f[100005];
int main()
{
	scanf("%d%d",&n,&m);
	memset(f,0x3f,sizeof(f));
	f[0]=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&w,&v);
		for(int j=n*1000;j>=v;j--)
		  f[j]=min(f[j],f[j-v]+w);
	}
	for(int i=n*1000;i>=0;i--)
	{
		if(f[i]<=m)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 896
import sys
N,M = map(int,input().split())
A = list(map(int,input().split()))
ans = []
border = sum(A) * (1 / (4*M))
for i in range(M):
    max_a = max(A)
    
    if max_a == 0 or max_a < border:
        print('No')
        sys.exit()

    for j in range(N):
        if A[j] == max_a:
            A[j] = 0

print('Yes')

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9 + 7;
const int maxn = 1e6 + 5;


struct dsu0 {
    vector<int> par, siz;
    int n;
    int cc;
    int largest;
    void init(int n) {
	assert(n>0);
	this->n=n;
	cc=n;
	par.resize(n+10);siz.resize(n+10);
	for (int i=0; i<n; i++) par[i]=i,siz[i]=1;
	largest=1;
    }
    int parent(int x) {
	assert(x>=0 && x<n);
	return par[x]==x?x:par[x]=parent(par[x]);
    }
    bool join(int x, int y) {
	x=parent(x);y=parent(y);
	if (x==y) return false;
	cc--;
	if (siz[x]<siz[y]) swap(x,y);
	siz[x]+=siz[y];par[y]=x;
	largest=max(largest,siz[x]);
	return true;
    }
};

ll pw(ll x, ll y) {
    ll res=1;
    while (y) {
	if (y%2) res=res*x%mod;
	x=x*x%mod;y=y/2;
    }
    return ((res%mod)+mod)%mod;
}

int n, m;
int u[maxn], v[maxn];
ll w[maxn];

ll x;

vector<int> ord;

ll st(int mustUse=-1) {
    dsu0 dsu;
    dsu.init(n);
    ll tot = 0;
    if (~mustUse) {
	tot += w[mustUse];
	dsu.join(u[mustUse], v[mustUse]);
    }
    for (int i: ord) {
	if (dsu.join(u[i],v[i])) {
	    tot += w[i];
	}
    }

    return tot;
}

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

    cin>>n>>m;
    cin>>x;
    for (int i=0; i<m; i++) {
	cin>>u[i]>>v[i]>>w[i];
	--u[i]; --v[i];
    }
    
    ord.resize(m);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i, int j) {
	    return w[i]<w[j];
	});


    ll mst = st();
    if (mst > x) {
	out(0);
    }

    
    ll slack = 0;
    ll target = 0;

    for (int i=0; i<m; i++) {
	ll res = st(i);
	if (res == x) {
	    target++;
	} else if (res > x) {
	    slack++;
	}
    }

    // watch(slack);
    // watch(target);

    if (target == 0) {
	out(0);
    }


    
    if (mst == x) {
	// Any edge that is part of an MST can be whatever colors, as long as not all same
	ll res = pw(2, slack) * (pw(2, target)-2) % mod;
	res %= mod;
	res += mod;
	res %= mod;
	out(res);
    }

    assert(x > mst);

    // X-ST can be BBBBBB..W or WWWWW..B, then slacker edges can be whatever
    ll res = 2*(pw(2,target)-1)%mod*pw(2, slack) % mod;

    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;
    
    return 0;
}


// 1. if mst<x, all edges of mst must be same color, otherwise we'd pick it over x-st/
// 2. mst needs to be 1 edge tweak away from x-st. this is because if one of the "tweaked" edges is opposite color,
// then we'd just pick that "semi-tweaked" st instead of tweaking all the way to the full x-st


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

int main(){
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    
    int awake = 60 * (H2 - H1) + (M2 - M1) - K;
    cout  << awake << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vint;
const int inf=1e9;
int dist[1010];
int s[2010],t[2010],d[2010];
int main(){
    int v,e,r;  cin>>v>>e>>r;
    for(int i=0;i<v;i++)    dist[i]=inf;
    dist[r]=0;
    for(int i=0;i<e;i++)    cin>>s[i]>>t[i]>>d[i];
    int i=0;
    for(;i<v;i++){
        bool updated=false;
        for(int j=0;j<e;j++){
            if(dist[s[j]]==inf) continue;
            if(dist[t[j]]>dist[s[j]]+d[j]){
                updated=true;
                dist[t[j]]=dist[s[j]]+d[j];
            }
        }
        if(updated==false)   break;
    }
    if(i<v){
        for(int i=0;i<v;i++){
            if(dist[i]==inf)    cout<<"INF"<<endl;
            else    cout<<dist[i]<<endl;
        }
    }
    else    cout<<"NEGATIVE CYCLE"<<endl;
    return 0;
}

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

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

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

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

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

      return tokenizer.nextToken("\n");
    }

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

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

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

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

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

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int[] l = sc.nextIntArray(n);
    int count = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        if (l[i] == l[j]) continue;
        for (int k = j + 1; k < n; k++) {
          if (l[k] == l[i] || l[k] == l[j]) continue;
          if (l[i] + l[j] <= l[k]) continue;
          if (l[i] + l[k] <= l[j]) continue;
          if (l[k] + l[j] <= l[i]) continue;
          count++;
        }
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 33572
#include <stdio.h>

int main() {
    char str[1000];
    int i, accept;
    
    while (fgets(str,1000,stdin) != NULL) {
        str[strlen(str)] = '\0';
        accept = 1;
        while (accept) {
            for (i = 0; i < strlen(str); i++) {
                if ('a' <= str[i] && str[i] <= 'y') {
                    str[i]++;
                } else if (str[i] == 'z') {
                    str[i] = 'a';
                }
            }
            
            for (i = 0; i < strlen(str) - 3; i++) {
                if (str[i] == 't') {
                    if (str[i+1] == 'h') {
                        if (str[i+2] == 'e') {
                            accept = 0;
                            break;
                        } else if (str[i+2] == 'a') {
                            if (str[i+3] == 't') {
                                accept = 0;
                                break;
                            }
                        } else if (str[i+2] == 'i') {
                            if (str[i+3] == 's') {
                                accept = 0;
                                break;
                            }
                        }
                    }
                }
            }
        }
        printf("%s", str);
    }
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void){

	while(1){
		int c,i;
		scanf("%d",&c);
		if(!c) break;
		int max = 0, min = 1000, sum = 0;
		for(i=0; i<c; i++){
			int n;
			scanf("%d",&n);
			max = ((max>n)? max:n);
			min = ((min<n)? min:n);
			sum += n;
		}
		sum -= (max + min);
		printf("%d\n",sum/(c-2));
	}

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(9);
  for (int i = 0; i < N; i++) {
    int X;
    cin >> X;
    if (X < 3200) A.at(X / 400) = 1;
    else A.at(8) ++;
  }
  int K = 0;
  for (int i = 0; i < 8; i++) K += A.at(i);
  if (K == 0) cout << 1 << " " << A.at(8) << endl;
  else cout << K << " " << K + A.at(8) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
const int MAX=4005;
int ans=INF,n,dist;
vector<int> pt,len;
char a[MAX],b[MAX];
int chk[MAX];
priority_queue<pii> inch;
int main(){
    scanf(" %s %s",a,b);
    n=strlen(a);
    for(int i=0;i<n;i++) if(b[i]=='1') pt.push_back(i);
    if(pt.size()==1) len.push_back(n);
    else for(int i=0;i<pt.size();i++) len.push_back((pt[(i+1)%pt.size()]-pt[i]+n)%n);
    if(pt.empty()){
        for(int i=0;i<n;i++) if(a[i]=='1'){
            printf("-1\n");
            return 0;
        }
        printf("0\n");
        return 0;
    }
    for(int i=0;i<n;i++){
        dist=0;
        for(int j=0;j<n;j++) {
            if(a[j]!=b[(j+i)%n]) dist++,chk[(j+i)%n]=1;
            else chk[(j+i)%n]=0;
        }
        inch.push(make_pair(0,0));
        for(int j=0;j<pt.size();j++){
            for(int k=(pt[j]+1)%n;k!=pt[(j+1)%pt.size()];k=(k+1)%n){
                if(chk[k]) {
                    int t=(k-pt[j]+n)%n;
                    inch.push(make_pair(t,len[j]-t));
                }
            }
        }
        int t1=inch.top().first,t2=0,smin1=max(t1-i,0),smin2=t1;
        while(inch.size()>=2){
            pii tmp=inch.top();
            inch.pop();
            t2=max(t2,tmp.second);
            t1=inch.top().first;
            smin1=min(smin1,max(t1-i,0)+t2);
            smin2=min(smin2,t1+max(t2-(n-i)%n,0));
        }
        ans=min(ans,dist+2*smin1+i);
        ans=min(ans,dist+2*smin2+(n-i)%n);

    }
    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N;
main(){
  cin>>N;
  vector<vector<int>>specials;
  for(int i=1;i<=N;++i){
    if(i%2==0)continue;
    //cout<<i<<": ";
    vector<int>divisors;
    for(int j=1;j<=i;++j){
      if((double)i/j!=i/j)continue;
      divisors.push_back(j);
      //cout<<j<<",";
    }
    //cout<<" -> "<<divisors.size()<<endl;
    if(divisors.size()==8)specials.push_back(divisors);
  }
  cout<<specials.size()<<endl;
}


Measured memory_bytes: 256
// iostream のscanf, printf では間に合わなかった
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

#define INF (1<<29)
#define mp make_pair
#define pb push_back

typedef pair<int,int> pii;

int main(){
	int n, m;
	cin >> n >> m;
	vector<pii> treasure;
	for( int i = 0; i < n; i++ ){
		int x, y;
		//cin >> x >> y;
		scanf("%d %d", &x, &y);
		treasure.pb( mp(x,y) );
	}
	sort(treasure.begin(), treasure.end());
	for( int i = 0; i < m; i++ ){
		int x1, y1, x2, y2;
		//cin >> x1 >> y1 >> x2 >> y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
		// search
		int ans = 0;
		vector<pii>::iterator it = lower_bound(treasure.begin(),treasure.end(),mp(x1,y1));
		while( 1 ){
			if( it == treasure.end() || *it > mp(x2,y2) ) break;
			//if( (*it).first > x2 ) it = upper_bound(treasure.begin(), treasure.end(),mp(-INF,(*it).second+1));
			if( x1 <= (*it).first && (*it).first <= x2 && y1 <= (*it).second && (*it).second <= y2 ) ans++;
			it++;
		}
		//cout << ans << endl;
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1336