akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0226
{
    class Program
    {
        static void Main(string[] args)
        {

            while (true)
            {
                string[] vs = RArSt();
                if (vs.All(x => x == "0")) break;

                string a = vs[0];
                string b = vs[1];

                int hit = 0;
                int blow = 0;
                for (int i = 0; i < a.Count(); i++)
                {
                    if (a.Contains(b[i]))
                    {
                        if (a[i] == b[i]) hit++;
                        else blow++;
                    }
                }
                Console.WriteLine("{0} {1}", hit, blow);
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



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

long long mypower(int n, int p)
{
	long long ans = 1;
	for(int i = 0; i < p; i++){
		ans = (ans * n) % 1000000007;
	}
	return ans;
}

int main()
{
	int N = 0;
	cin >> N;
	int num = 0;
	if((N % 2)){
		num = (N - 1) / 2;
	}else{
		num = N / 2;
	}
	map<int, int> m;
	bool wrong_report = false;
	for(int i = 0; i < N; i++){
		int tmp = 0;
		cin >> tmp;
		m[tmp]++;
		if(m[tmp] > 2){
			wrong_report = true;
			break;
		}
		if(!(N % 2) && m[0] > 0){
			wrong_report = true;
			break;
		}
		if((N % 2) && m[0] > 1){
			wrong_report = true;
			break;
		}
	}
	if(wrong_report){
		cout << 0 << endl;
	}else{
		cout << mypower(2, num) << endl;
	}
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

/* Union-Find-Tree */
class Union_Find {
public:
  vector<long long> par;
  vector<long long> rnk;

  Union_Find (long long n) {
    // par.resize(n), rnk.resize(n);
    for (int i = 0; i < n; ++i) {
      par.pb(i);
      rnk.pb(0);
    }
  }

  // 木の根を求める
  int find(int x) {
    if (par[x] == x)
    return x;
    else
    return par[x] = find(par[x]);
  }

  // xとyの属する集合を併合
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    if (rnk[x] < rnk[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }

  // xとyが同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  ll n,k,l; cin >> n >> k >> l;
  Union_Find road(n), train(n);

  vector<pair<int,int>> r,t;
  rep(i,k) {
    ll p,q; cin >> p >> q;
    road.unite(--p,--q);
    r.pb({p,q});
  }

  rep(i,l) {
    ll r,s; cin >> r >> s;
    train.unite(--r, --s);
    t.pb({r,s});
  }

  vector<pair<int,int>> com;
  map<pair<int,int>, int> sum;

  rep(i,n) {
    ll a,b; a = road.find(i), b = train.find(i);
    com.pb({a,b});
    sum[{a,b}] += 1;
  }

  rep(i,n) {
    cout << sum[com[i]] << " ";
  }
  END;
}


Measured memory_bytes: 21604
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    auto s = readln.chomp;
    writeln(s.startsWith("YAKI") ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef long long LL;

static const int INF = INT_MAX;
static const int MIN = INT_MIN;
static const LL L_INF = LLONG_MAX;
static const int MOD = 1000000000 + 7;
static const int SIZE = 100005;

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

    int a, b, c, x, y;
    int money = 0;
    cin >> a >> b >> c >> x >> y;

    if( a + b > c * 2 ) {
        if( x > y ) {
            money += y * c * 2;
            x -= y;
            if( a < c * 2 ) {
                money += x * a;

            } else {
                money += x * c * 2;

            }

        } else {
            money += x * c * 2;
            y -= x;
            if( b < c * 2 ) {
                money += y * b;

            } else {
                money += y * c * 2;

            }

        }

    } else {
        money = x * a + y * b;

    }
    cout << money << endl;

    return 0;
}



Measured memory_bytes: 256
# coding: utf-8
N, M = map(int, input().split())
S = []
for i in range(M):
    tmp = list(map(int, input().split()))
    S.append(tmp[1:])
P = list(map(int, input().split()))
ans = 0
# print(S)
for bit in range(2**N):
    l = []
    for j in range(N):
        if bit >> j & 1 == 1:
            l.append(1)
        else:
            l.append(0)
    flag = True
    for j in range(M):
        t = S[j]
        cnt = 0
        for k in range(len(S[j])):
            if l[t[k]-1] == 1:
                cnt += 1
            # else:
            #     flag = False
        if cnt % 2 != P[j]:
            flag = False
    if flag:
        # print(bin(bit))
        ans += 1
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            while (Console.ReadLine() != "0")
            {
                var S = Console.ReadLine().Split(' ').AsEnumerable();
                var count = 0;
                while (true)
                {
                    var P = Frequency(S);
                    if (S.SequenceEqual(P))
                        break;
                    S = P;
                    count++;
                }
                Console.WriteLine(count);
                Console.WriteLine(string.Join(" ", S.ToArray()));
            }
        }

        static IEnumerable<string> Frequency(IEnumerable<string> S)
        {
            var cache = new Dictionary<string, string>();
            foreach (var n in S)
            {
                if (cache.ContainsKey(n))
                {
                    yield return cache[n];
                }
                else
                {
                    cache.Add(n, S.Count(i => i == n).ToString());
                    yield return cache[n];
                }
            }
        }
    }
}

Measured memory_bytes: 6216
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef long long int ll;

int n;
int a[200200];
vector<int> g[200200];
int res[200200];
vector<int> v;

void dfs(int s,int p){
    int it=lower_bound(v.begin(),v.end(),a[s])-v.begin();
    int change=-1;
    if(it==v.size()){
        v.push_back(a[s]);
    }
    else{
        change=v[it];
        v[it]=a[s];
    }
    res[s]=v.size();
    for(int t:g[s]){
        if(t!=p){
            dfs(t,s);
        }
    }
    if(change==-1){
        v.pop_back();
    }
    else{
        v[it]=change;
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=1;i<n;i++){
        int x,y; cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(0,-1);
    for(int i=0;i<n;i++){
        printf("%d\n",res[i]);
    }
}


Measured memory_bytes: 27692
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(){
	int N,K;
	int l[51];
	cin >> N >> K;
	for(int i=0;i<N;i++){
		cin >> l[i];
	}
	int max;
	int Ans=0;
	for(int i=0;i<K;i++){
		max=0;
		for(int j=1;j<N;j++){
			if(l[max]<l[j]){
				max=j;
			}
		}
		Ans+=l[max];
		l[max]=-1;
	}
	cout << Ans;
	cout << endl;
	return 0;
}


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

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pull pair<ull, ull>
#define m_p make_pair

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	
	bool ok=1;
	int i=0, j=(s.size()/2) - 1;
	while(i <= j){
		if(s[i] != s[j]){
			ok=0;
			break;
		}
		i++;j--;
	}
	
	i=(s.size()/2) + 1;j=s.size()-1;
	while(i <= j){
		if(s[i] != s[j]){
			ok=0;
			break;
		}
		i++;j--;
	}
	
	i=0;j=s.size()-1;
	while(i <= j){
		if(s[i] != s[j]){
			ok=0;
			break;
		}
		i++;j--;
	}
	
	cout << (ok ? "Yes" : "No");
}


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

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int count = 0;

    rep(i, N - 2)
    {

        if (S.substr(i, 3) == "ABC")
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
def abc177c():
    n = int(input())
    a = list(map(int, input().split()))
    a_cum = [0] * n
    a_cum[-1] = a[-1]
    for i in range(n - 2, -1, -1):
        a_cum[i] = a_cum[i + 1] + a[i]
    total = 0
    for i in range(n - 1):
        total += a[i] * a_cum[i + 1]
    print(total % (pow(10,9)+7))

abc177c()

Measured memory_bytes: 31432
#include<iostream>
#include<vector>

int main (){
    std::cin.tie(0); 
	std::ios::sync_with_stdio(false);
    int N,K;std::cin >> N >> K;
    std::vector<int> A(N);
    for (int i=0;i<N;++i){
        std::cin>>A[i];
    }
    std::string YES="Yes";
    std::string NO="No";

    for (int i=K;i<N;++i){
        if ( A[i] > A[i-K] ) {
            std::cout << YES;
        } else {
            std::cout << NO;
        }
        std::cout << std::endl;
    }

    return 0 ;
}

Measured memory_bytes: 3984
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int L;

	while(cin >> L, L) {
		vvi money(12, vi(2));
		REP(i, 12) {
			cin >> money[i][0] >> money[i][1];
		}
		int sum = 0;
		REP(i, 12) {
			sum += money[i][0]-money[i][1];
			if(sum >= L) {
				cout << i+1 << endl;
				break;
			}
		}

		if(sum < L) {
			cout << "NA" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstdlib>
#include <cstring>
struct Node
{
    int key;
    Node *next, *prev;
};

Node *nil;

Node *listSearch(int key)
{
    Node *cur = nil->next;
    while (cur != nil && cur->key != key)
    {
        cur = cur->next;
    }
    return cur;
}

void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList()
{
    Node *cur = nil->next;
    int isf = 0;
    while (1)
    {
        if (cur == nil)
            break;
        if (isf++ > 0)
            printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
void deleteNode(Node *t)
{
    if (t == nil)
        return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

void deleteFirst()
{
    deleteNode(nil->next);
}

void deleteLast()
{
    deleteNode(nil->prev);
}

void deleteKey(int key)
{
    /* your code */
    deleteNode(listSearch(key));
}

void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main()
{
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for (i = 0; i < n; i++)
    {
        scanf("%s%d", com, &key);
        if (com[0] == 'i')
        {
            insert(key);
            np++;
            size++;
        }
        else if (com[0] == 'd')
        {
            if (strlen(com) > 6)
            {
                if (com[6] == 'F')
                    deleteFirst();
                else if (com[6] == 'L')
                    deleteLast();
            }
            else
            {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }

    printList();
    return 0;
}


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

typedef long long LL;

using namespace std;

int main()
{
	LL x,M,ans;
	cin>>x;
	M = x % 11;
	ans = (x/11)*2;
	if (M > 0)
	{
		if (M<=6) ans++;
		else ans+=2;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#coding:utf-8

s = list(input())

a = int(s[0])*10 + int(s[1])
b = int(s[2])*10 + int(s[3])

if 0 < a < 13 and 0 < b < 13:
    print("AMBIGUOUS")
elif 0 < a < 13 and (b >= 13 or b == 0):
    print("MMYY")
elif ( a == 0 or a >= 13) and 0 < b < 13:
    print("YYMM")
else:
    print("NA")

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

int main () {
    int N;
    scanf("%d", &N);
    int *A = malloc((1+N) * sizeof(int));
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }
    int *B = malloc((1+N) * sizeof(int));
    for (int i = 1; i <= N; i++) {
        scanf("%d", &B[i]);
    }
    int *C = malloc(N * sizeof(int));
    for (int i = 1; i < N; i++) {
        scanf("%d", &C[i]);
    }

    int ans = B[A[1]];
    for (int i = 2; i <= N; i++) {
        int prev = A[i-1];
        int current = A[i];
        ans += B[A[i]];
        if (current == (prev + 1))
            ans += C[current-1];
    }
    printf("%d\n", ans);


    return 0;
}


Measured memory_bytes: 128
#require 'pp'

s = gets.chomp!.chars
q = gets.to_i

reverse = false
memo = []

q.times do |i|
    q1, q2, q3 = gets.split
    if q1 == '1'
        # 反転
        reverse = !reverse
    else
        if q2 == '1'
            # 先頭に追加
            if reverse == false
                memo << [q3, :head]
            else
                memo << [q3, :tail]
            end
        else
            # 末尾に追加
            if reverse == false
                memo << [q3, :tail]
            else
                memo << [q3, :head]
            end
        end
    end
end

ans = 
    if reverse == false
        s
    else
        s.reverse
    end
    
memo.each do |m|
    if reverse == false
        if m[1] == :head
            ans.unshift(m[0])
        else
            ans.push(m[0])
        end
    else
        if m[1] == :head
            ans.push(m[0])
        else
            ans.unshift(m[0])
        end
    end
end

puts ans.join


Measured memory_bytes: 41980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 1;
  for (int i = 0; i < N; i++) {
    if (sum < K) {
      sum *= 2;
    }
    else {
      sum += K;
    }
  }
  
  cout << sum << endl;
}

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

using namespace std;
typedef long long ll;


vector<ll> rain_flows_into_dams(vector<ll> a) {
  vector<ll> ans;

  ll acc = 0;
  for(ll i = 0;i<a.size();i++) {
    if(i % 2 == 0) {
      acc += a.at(i);
    } else {
      acc -= a.at(i);
    }
  }
  ans.push_back(acc);
  for(ll i = 0; i<a.size()-1;i++) {
    ll y = ans.at(i) / 2;
    ans.push_back((a.at(i) - y)*2);
  }
  return ans;
}


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);

  for(ll i= 0;i<n;i++) {
    cin >> a[i];
  }
  vector<ll> ans = rain_flows_into_dams(a);

  for(ll i =0; i < ans.size();i++) {
    cout << ans[i];
    if(i != ans.size() - 1) {
      cout << " ";
    }
  }
}

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

#define int long long
#define rep(i,a,n) for(int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort((c).begin(), (c).end(), greater<int>());
#define fi first
#define se second
  
typedef pair<int,int> P;
typedef vector<int> vi;

int N;
int INF=1e9+7;

signed main() {
    cin>>N;

    int dp[N+1][4][4][4]={};
    // dp[i][a][b][c] i番目までで直近の三文字がabcの場合の数
    // 0123 TAGC

    dp[0][0][0][0]=1;
    rep(i,0,N) {
        rep(a,0,4) {
            rep(b,0,4) {
                rep(c,0,4) {
                    rep(d,0,4) {
                        if((b==1 and c== 2 and d==3) or (b==1 and c==3 and d==2) or (b==2 and c==1 and d==3)) continue;
                        if((a==1 and c==2 and d==3) or (a==1 and b==2 and d==3)) continue;

                        dp[i+1][b][c][d] += dp[i][a][b][c];
                        if(dp[i+1][b][c][d]>INF) dp[i+1][b][c][d] %= INF;
                    }
                }
            }
        }
    }

    int ans=0;
    rep(a,0,4) {
        rep(b,0,4) {
            rep(c,0,4) {
                ans+=dp[N][a][b][c];
                if(ans>INF) ans%=INF;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 256
// 051 C - Back and Forth 2017/01/07

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int gcd(int a, int b) {
    if(a<b) swap(a,b);
    return b ? gcd(b, a%b) : a;
}

int main(){
    int n;int X;cin >> n >> X;
    vector<int> x(n);
    rep(i ,n){
        cin >> x[i];
    }
    vector<int> dx(n);
    int ans=0;
    rep(i , n){
       dx[i]=abs(X-x[i]);
       ans=gcd(ans,dx[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String p = sc.next();
		String ss = s+s;
		
		String[] sArray = ss.split(p);
		if(sArray.length>1 || p.equals(s)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}	
}

Measured memory_bytes: 26244
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class F
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int M = GetInt();
		int[] A = new int[M];
		int[] B = new int[M];
		var adj = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();
		for(int i = 0; i < M; i++)
		{
			A[i] = GetInt() - 1;
			B[i] = GetInt() - 1;
			adj[A[i]].Add(B[i]);
		}

		int INF = int.MaxValue / 2;
		int[][] cost = new int[N][];
		int[][] prev = new int[N][];
		for(int i = 0; i < N; i++)
		{
			cost[i] = Enumerable.Repeat(INF, N).ToArray();
			prev[i] = new int[N];
			bfs(N, adj, i, cost[i], prev[i]);
		}

		int min = INF;
		int argMin = -1;
		for(int i = 0; i < M; i++)
		{
			int d = cost[B[i]][A[i]];
			if(d == INF)
				continue;

			if(d < min)
			{
				min = d;
				argMin = i;
			}			
		}
		if(min == INF)
		{
			Console.WriteLine(-1);
			return;
		}

		var list = new List<int>();
		list.Add(A[argMin] + 1);
		int current = A[argMin];
		for(int i = 0; i < min; i++)
		{
			current = prev[B[argMin]][current];
			list.Add(current + 1);
		}

		Console.WriteLine(min + 1);
		Console.WriteLine(string.Join("\n", list.Select(x => x.ToString()).ToArray()));
	}

	private void bfs(int N, List<int>[] adj, int s, int[] cost, int[] prev)
	{
		bool[] visited = new bool[N];
		var queue = new Queue<int>();
		cost[s] = 0;
		visited[s] = true;
		queue.Enqueue(s);
		while(queue.Count > 0)
		{
			int v = queue.Dequeue();
			foreach(int u in adj[v])
			{
				if(visited[u])
					continue;

				cost[u] = cost[v] + 1;
				prev[u] = v;
				visited[u] = true;
				queue.Enqueue(u);
			}
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 29580
#include<iostream>
#include<vector>
using namespace std;
double temp(double H,double T){

  return T-(0.006*H);
}
int main(){

  int N;
  double T,A;
  cin>>N>>T>>A;
  vector<int>H(N);
  for(int i=0;i<=N-1;i++){
  
    cin>>H[i];
  }
  int ans=0;
  double min=999999;
  for(int i=0;i<=N-1;i++){
  
    if(min>abs(A-temp(H[i],T))){
    
      min=abs(A-temp(H[i],T));
      ans=i+1;
    }
  }
  cout<<ans;
  return 0;
}

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

int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int solve(int n){
    vector<int> l(n),t(n),r(n),b(n);
    for(int i=0;i<n;i++) cin>>l[i]>>t[i]>>r[i]>>b[i];

    set<int> xs,ys;
    for(int i=0;i<n;i++) xs.insert(l[i]),xs.insert(r[i]),ys.insert(t[i]),ys.insert(b[i]);
    xs.insert(1e8);
    xs.insert(-1);
    ys.insert(1e8);
    ys.insert(-1);
    map<int,int> mpx,mpy;
    int idx=0;
    for(auto &e:xs) mpx[e]=idx++;
    int idy=0;
    for(auto &e:ys) mpy[e]=idy++;
    vector<vector<long long>> f(idx,vector<long long>(idy,0LL));

    for(int i=0;i<n;i++){
        for(int x=mpx[l[i]];x<mpx[r[i]];x++){
            for(int y=mpy[b[i]];y<mpy[t[i]];y++){
                f[x][y]+=(1LL<<i);
            }
        }
    }
    int res=0;
    function<void(int,int,long long)> dfs=[&](int x,int y,long long c){
        if(x<0 || idx<=x || y<0 || idy<=y) return;
        if(f[x][y]!=c) return;
        f[x][y]=-1;
        for(int i=0;i<4;i++){
            dfs(x+dx[i],y+dy[i],c);
        }
    };
    for(int i=0;i<idx;i++){
        for(int j=0;j<idy;j++){
            if(f[i][j]!=-1){
                res++;
                dfs(i,j,f[i][j]);
            }
        }
    }
    return res;
}

int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,k,n) for (ll i = k; i < n; ++i)
#define inputar(a,n) ll a[n];rep(i,0,n)cin>>a[i]
#define PI 3.14159265
const int MOD=1e9+7;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a)  (a).begin(),(a).end()

#define test4(x,y,z,a) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cerr<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cerr<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cerr<<"x is "<<x<<endl;

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

int main()
{
    IOS;
    ll n;
    cin>>n;
    ll a[n+1];
    ll ne=0;
    ll mn=LONG_LONG_MAX;
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]<0) ne++;
        mn=min(mn,abs(a[i]));
        sum+=abs(a[i]);
    }
    if(ne%2)
    {
        cout<<sum-(2*mn)<<endl;
    }
    else
    {
        cout<<sum<<endl;
    }
    



}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int n,k,a[5555],p,re,ans;
int main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++)
	{
		re=k;
		for (int j=n;j>=1;j--)
		{
			if (j==i) continue;
			if (a[j]<re) re-=a[j];
		}
		if (re<=a[i]) ans++;
	}
	cout<<n-ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    #include <vector>
    #include <string>
    #include <cmath>
    #include <algorithm>
    #include <utility>
    #include <queue>
    #include <set>
    #include <map>
    #include <deque>
    #include <iomanip>
    #include <cstdio>
     
    using namespace std;
    typedef  long long ll;
    typedef pair<int,int> PII;
    typedef vector<int> VI;
    typedef vector<VI> VVI;
    #define  MP make_pair
    #define  PB push_back
    #define inf  1000000007
    #define rep(i,n) for(int i=0;i<(int)(n);++i)
    ll gcd(ll v,ll b){
    	if(v>b) return gcd(b,v);
    	if(v==b) return b;
    	if(b%v==0) return v;
    	return gcd(v,b%v);
    }
    int main(){
        int t;
        cin >> t;
        rep(zz,t){
            ll a,b,c,d;
            cin >> a >> b >> c>> d;
            bool flag = 0;
            if(b>d)flag = 1;
            if(a<b)flag = 1;
            ll x = gcd(b,d);
            ll y = (a-c-1)%x;
            if(c+1+y<b)flag = 1;
            if(flag){
                cout << "No" << endl;
            }else{
                cout << "Yes" << endl;
            }
        }
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const ll mod = 1000000009;
const int p = 2333;
map<ll,int>has1;
ll hh[50015]={0};
ll pow1[50015]={0};
char s[50005]={0};
ll gethashcode(int i,int m){
    return (hh[i+m-1]-hh[i-1]*pow1[m]%mod+mod)%mod;
}
int n;
ll num;
int check(int m){
    has1.clear();
    for(int i=1;i+m-2<=n;i++){
        num=gethashcode(i,m);
       // cout << num <<endl;
        if(has1[num]){
            if(has1[num]+m<=i){
                return 1;
            }
        }
        else
            has1[num]=i;
    }
    return 0;
}
int main()
{
    pow1[0]=1;
    for(int i=1;i<50005;i++){
        pow1[i]=pow1[i-1]*p%mod;
    }
    scanf("%d",&n);
    scanf("%s",s+1);
    hh[0]=0;
    for(int i=1;i<=n;i++)
        hh[i]=(hh[i-1]*p%mod+s[i]-'a')%mod;
    int ans = 0 ;
    int l=1,r=n;
    while(l<r){
        int m=(l+r)/2;
        if(check(m)){
            ans=m;
            l=m+1;
        }
        else
            r=m;
    }
    printf("%d\n",ans);
    return 0;
}
//
//13
//orangerangeao



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
map<ll,bool> m;
int main(){
    //freopen("fibsubseq.in","r",stdin);
    //freopen("fibsubseq.out","w",stdout);
    ll n,x;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x;
        if(m[x])m[x]=false;
        else m[x]=true;
    }
    ll cnt=0;
    for(auto i:m){
        if(i.second)cnt++;
    }
    cout<<cnt;
return 0;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mem(arr,v) memset(arr,v,sizeof(arr))
/*bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
} */
int main()
{
     ll t,pk,mn=INT_MAX;
     string str;
     cin>>str;
     for(int i=0;i<str.size()-2;i++)
     {
         string st;
         st+=str[i];
         st+=str[i+1];
         st+=str[i+2];
         stringstream s;
         s<<st;
         s>>pk;
         mn=min(abs(753-pk),mn);
     }
     cout<<mn<<endl;
}



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

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

	int x;
	cin >> x;

	bitset<1000200> bs;
	bs.set(0);
	rep (i, 1000000)
	{
		if (bs.test(i))
		{
			bs.set(i + 100);
			bs.set(i + 101);
			bs.set(i + 102);
			bs.set(i + 103);
			bs.set(i + 104);
			bs.set(i + 105);
		}
	}
	cout << bs.test(x) << endl;
}


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

int main()
{
    int a,b,i;
    cin>>a>>b;
	for( i=1;i<=2000000;i++)
    {
		if((i*8)/100 == a && (i*10)/100 ==b)
        {
            cout<<i<<endl;
            break;
        }
    }
    if(i==2000001)
    {
		cout<<"-1"<<endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
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;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int H, W;
string s[555];
int a[555][555], b[555][555];

void pnt(int x) {
    if (x)
        cout << '#';
    else
        cout << '.';
    return;
}

void solve() {
    FOR (i, 1, H - 1) {
        if (i & 1) {
            FOR (j, 1, W - 1) {
                a[i][j] = 1;
            }
        } else {
            if (i % 4) {
                a[i][1] = 1;
            } else
                a[i][W - 2] = 1;
        }
    }
    FOR (H) {
        FOR (j, W) {
            b[i][j] = !a[i][j];
            chmax(a[i][j], (int)s[i][j]);
            chmax(b[i][j], (int)s[i][j]);
        }
    }
    FOR (H) {
        FOR (j, W) {
            pnt(a[i][j]);
        }
        cout << endl;
    }
    cout << endl;
    FOR (H) {
        FOR (j, W) {
            pnt(b[i][j]);
        }
        cout << endl;
    }
}

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

    cin >> H >> W;
    FOR (H)
        cin >> s[i];

    FOR (H) {
        for (auto& c : s[i])
            if (c == '#')
                c = 1;
            else
                c = 0;
    }
    solve();
    return 0;
}


Measured memory_bytes: 5632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#define io ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
ll a[maxn],pre[maxn];//,sum[maxn];
const int mod=1e9+7;
void solve(){
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')s+="es";
    else s+="s";
    cout<<s;
}
int main(){
    io;
    //int T;cin>>T;
    //while(T--)
        solve();
}


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

const int N=2e5+10;

int n;
int a[N];
int b[N];

int main()
{
	ios::sync_with_stdio(0);
	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	    int x; cin>>x;
	    a[i]=a[i-1]+x; b[i]=b[i-1]^x;
	}
	
	int l=1; 
	long long sum=0;
	
	for(int i=1;i<=n;i++)
	{
	    while(a[i]-a[l-1]!=(b[i]^b[l-1])) l++;
	    sum+=i-l+1;
	}
	
	cout<<sum<<endl;
    return 0;
}


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


def solve(R: int, G: int, B: int, N: int):
    cnt= 0
    for r in range(0, N + 1, R):
        upper = N + 1 - r
        for g in range(0, upper, G):
            temp = upper-1-g
            if temp < 0:
                break
            b = temp / B
            if b % 1 == 0 and b >= 0:
                cnt += 1
            else:
                continue
    print(cnt)
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Dictionary<string, int> vs = new Dictionary<string, int>();

            var maxVal = 1;

            for (int i = 0; i < n; i++)
            {
                var oneString = Console.ReadLine();
                if (vs.ContainsKey(oneString))
                {
                    vs[oneString]++;
                    maxVal = Math.Max(maxVal, vs[oneString]);
                }
                else
                {
                    vs.Add(oneString, 1);
                }
            }

            var ans = vs.Where(tmp => tmp.Value == maxVal).Select(tmp => tmp.Key).OrderBy(tmp => tmp, StringComparer.Ordinal);
            
            foreach(var tmp in ans)
            {
                Console.WriteLine(tmp);
            }
            
        }
    }
}


Measured memory_bytes: 43760
<?php
// fscanf(STDIN,"%d %d %d %d",$a,$b,$c,$k);
$line = explode(" ", trim(fgets(STDIN)));
$num = explode(" ", trim(fgets(STDIN)));
$which = trim(fgets(STDIN));

if($which == $line[0]){
    echo $num[0] - 1,' ',$num[1];
}else{
    echo $num[0],' ',$num[1] -1;
}

?>

Measured memory_bytes: 4728
N = input()
A = input().split()
A = list(map(int, A))

B = []
C = []
for i in range(len(A)):
    if A[i]%2==0:
        if A[i]%3!=0:
            if A[i]%5!=0:
                B.append('DENIED')            
    elif A[i]%2!=0:
        C.append('DENIED')

if len(B)==0:
    if len(C)==N:
        print('DENIED')
    elif len(C)!=N:
        print('APPROVED')
elif len(B)!=0:
    print('DENIED')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i, m, n) for (ll i = m; i < (n); i++)
#define RFOR(i, m, n) for (ll i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
//#define print(ele) cout << (ele) << "\n"
#define print10(ele) cout << fixed << setprecision(10) << (ele) << "\n"

using namespace std;
typedef long long ll;
typedef vector<int> ivec;
typedef vector<string> svec;
typedef vector<ll> lvec;

const int mod = 1e9 + 7;
const ll INF = 1000000000000000000LL;

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

int main() {
  int k, a, b;
  cin >> k >> a >> b;
  if (a <= b / k * k)
    print("OK");
  else
    print("NG");
  return 0;
}

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

#include <iostream>
#include <fstream>

#include <iostream>

class abc082a {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int a, b;
	    in >> a >> b;
	    out << (a + b + 1) / 2 <<std::endl;

	}
};


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


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

int main(){
	ios;
	int a;
	string s;
	cin>>a>>s;
	if(a>=3200)
	{cout<<s<<endl;
	}
	else cout<<"red"<<endl;
	return 0;
	
}


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


int main()
{
     
     
  string s;
  cin>>s;
  if(s.length()==1)
    {
        if(s[0]=='3')
          cout<<"bon";
          
        else if(s[0]=='0' ||s[0]=='1'||s[0]=='6'||s[0]=='8')
           cout<<"pon";
           
        else
          cout<<"hon";
         
    }
    
 else if(s.length()==2)
  {
      if(s[1]=='3')
          cout<<"bon";
          
        else if(s[1]=='0' ||s[1]=='1'||s[1]=='6'||s[1]=='8')
           cout<<"pon";
           
        else
          cout<<"hon";
  }
  
  else
  {
      if(s[2]=='3')
          cout<<"bon";
          
        else if(s[2]=='0' ||s[2]=='1'||s[2]=='6'||s[2]=='8')
           cout<<"pon";
           
        else
          cout<<"hon";
  }
    
    return 0;    
        
} 


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <functional>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

ll x, k, d;

signed main() {
	std::random_device rnd;
	std::mt19937_64 mt(rnd());
	cin >> x >> k >> d;
	if (x < 0)x = abs(x);
	if (x / d >= k)cout << x - d * k << endl;
	else {
		if (x / d % 2 == k % 2)cout << x % d << endl;
		else cout << d - x % d << endl;
	}
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll n; cin >> n;
	string s; cin >> s;
	ll r=0, g=0, b=0;
	rep(i,n){
		if(s[i]=='R') r++;
		else if(s[i]=='G') g++;
		else b++;
	}
	ll ans = r*g*b;
	for(ll j=1; 2*j<=n; j++){
		for(ll i=0; i<n-2*j; i++){
			if(s[i]!=s[i+j] && s[i+j]!=s[2*j+i] && s[i]!=s[2*j+i]) ans--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int *higher = &a;
    if(b>*higher) higher=&b;
    if(c>*higher) higher=&c;
    *higher = 1;
    printf("%i\n", (a*b*c)/2);
    return 0;
} 

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main() {
	int n;

	cin >> n;

	for (int i = 1; i <= n; i++) {

		int x = i;

		if (x % 3 == 0) {
			cout << " " << i;
		}

		else if (x % 10 == 3) {
			cout << " " << i;
		}

		else {
			for (int j = 0; j < x; j++) {
				x /= 10;
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
			}
		}
	}
	cout << endl;

	return 0;
}


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

int main() {
    int N, result=0;
    cin >> N;
    int A[N], B[N], C[N-1];
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N-1) cin >> C[i];

    rep(i, N) {
        result += B[A[i]-1];
        if ((A[i+1]-A[i]) == 1 && (i+1) < N) {
            result += C[A[i]-1];
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	string str;
	while(true){
		cin >> str;
		if(cin.eof()){
			break;
		}
		int ans1, ans2;
		ans1 = 0;
		ans2 = 0;
		for(int i = 0; i < str.size() - 2; i++){
			if(str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I'){
				ans1++;
			}else if(str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I'){
				ans2++;
			}
		}
		
		printf("%d\n%d\n", ans1, ans2);
	}
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>

int main () {
int i,j;
char n[100000] = {0};
int  x[1001] = {0};

i = 0;
j = 0;


while(1) {
scanf("%c",&n[i]);
if(n[i] == '0' && n[i-1] == '\n'|| n[0] == '0') {break;}

if(n[i] >= '1' && '9' >= n[i] && n[i] != '\n') {
x[j] += n[i]-48;
}
  if(n[i] == '\n') {
j = j + 1;
}

i= i+1;

}

for(i=0; i < j;i++) {
printf("%d",x[i]);
printf("\n"); 

} 

return 0;

}



Measured memory_bytes: 2084
#pragma region 宣言部分
#include <iostream>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;

#pragma endregion


#define MAX_V 10000

struct edge {
    int to;
};


int V;
vector<edge> G[MAX_V];
bool mem[MAX_V]; //もう通ったか
int bc,wt;
bool flag;
int color[MAX_V];

void DFS(int u, bool f){
  mem[u] = true;
  if(color[u] == -1){
      if(f){
          color[u] = 1;
          bc++;
      }
      else{
          color[u] = 0;
          wt++;
      }
  }
  //writing method

  //method end

  REP(i,G[u].size()){
    if(color[u] == color[G[u][i].to]){
        flag = false;
    }
    if(!mem[G[u][i].to]){
      DFS(G[u][i].to, !f);
    }
  }
}

int main(){
    int n,m;
    cin >> n>> m;
    int a[n][n];
    vector <P> p;
    #pragma region 入力
    REP(i,n){
        REP(j,n){
            a[i][j] = 0;
        }
    }
    REP(i,m){
        int b,c;

        cin >> b >> c;
        b--;
        c--;
        a[b][c] = 1; 
        a[c][b] = 1;
    }
    REP(i,n){
        for(int j = i;j < n;j++){
            if(a[i][j] == 0 && i != j){
                edge e;
                e.to = j;
                G[i].pb(e);
                e.to = i;
                G[j].pb(e);
            }
        }
    }
    #pragma endregion
    
    REP(i,MAX_V){
        mem[i] = false;
        color[i] = -1;
    }
    flag = true;
    for(int i = 0;i < n;i++){
        bc = 0;
        wt = 0;
        if(!mem[i]){
            DFS(i,true);
        }
        if(bc != 0 || wt != 0)
            p.pb(mk(bc,wt));
    }
    if(!flag){
        cout << -1 << endl;
        return 0;
    }
    int dp[n+1][800];
    
    REP(j,n+1){
        REP(i,800){
            dp[j][i] = 0;
        }
    }   
    dp[0][0] = 1;
    for(int i = 0;i < p.size();i++){
        for(int j = 0;j < 702;j++){
            if(dp[i][j] != 0){
                dp[i+1][j+p[i].first]++;
                dp[i+1][j+p[i].second]++;
            }
        }
    }
    int res = 80000000;
    REP(i,800){
        if(dp[p.size()][i] != 0){
            int o = i;
            int t = n-i;
            int u = o*(o-1)/2 + t*(t-1)/2;
            //cout << u << endl;
            res  = min(res, u);
        }
    }
    /*
    REP(i,400){
        cout << dp[p.size()][i] << endl;
    }
    */
    //cout << res << "   " << sum-res << endl;
    /*
    REP(i,p.size()){
        cout << p[i].first << "   " <<  p[i].second << endl;
    }*/
    
    cout << res << endl;
  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

int main(){
    string s, t; cin >> s >> t;

    string s_d = s;
    string t_d = t;
    bool res; res = false;

    sort(all(s_d));
    sort(all(t_d), std::greater<int>());

    if(s_d.size() < t_d.size()) {
        for(int i = 0; i < s_d.size(); ++i) {
            if(s_d[i] != t_d[i]) {
                break;
            }

            if(i == s_d.size() - 1) {
                res = true;
            }
        }
    }

    for(int i = 0; i < s_d.size(); ++i) {
        if(s_d[i] != t_d[i]) {
            if(s_d[i] < t_d[i]) {
                res = true;
                break;
            }
        }
    }

    if(res == true) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256