akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    string str; // 文字列
    int m; // シャッフル回数
    int h; // 動かす文字数
    
    while(true){
        cin >> str;
        if(str.at(0) == '-') break;

        cin >> m;
        for(int i = 0; i < m; ++i){
            cin >> h;
            for(int j = 0; j < h; j++){
                char temp = str.at(0);
                for(int k = 0; k < str.size() - 1; k++){
                    str.at(k) = str.at(k + 1);
                }
                str.at(str.size() - 1) = temp;
            }
        }
        cout << str << endl;
    }
    return 0;
}



Measured memory_bytes: 3200
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a < b:
    if a + v * t >= b + w * t:
        print("YES")
    else:
        print("NO")
else:
    if a + v * t * (-1) <= b + w * t * (-1):
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9188
using System.Collections.Generic;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new List<P>[n];
        for (int i = 0; i < n; i++)
        {
            var c = int.Parse(Console.ReadLine().Trim());
            a[i] = new List<P>();
            for (int j = 0; j < c; j++)
            {
                string[] line = Console.ReadLine().Trim().Split(' ');
                var t1 = int.Parse(line[0]) - 1;
                var t2 = int.Parse(line[1]);
                a[i].Add(new P { x = t1, y = t2 });
            }
        }
        getAns(n, a);
    }
    static void getAns(int n, List<P>[] a)
    {
        var ans = 0;
        var imax = 1 << n;
        for (int i = 0; i < imax; i++)
        {
            var cb = countBit(i);
            if (cb > ans && check(n, a, i)) ans = cb;
        }
        Console.WriteLine(ans);
    }
    static bool check(int n, List<P>[] a, int i)
    {
        for (int j = 0; j < n; j++)
            if (((i >> j) & 1) == 1)
                foreach (var x in a[j])
                    if (((i >> x.x) & 1) != x.y) return false;
        return true;
    }
    static int countBit(int bits)
    {
        bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
        bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
        bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
        bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
        return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff);
    }
}


Measured memory_bytes: 13268
S = input()
A,B,C,D = int(S[0]),int(S[1]),int(S[2]),int(S[3])

if A+B+C+D == 7:
  print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
  
elif A+B+C-D == 7:
  print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
  
elif A+B-C+D == 7:
  print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
  
elif A+B-C-D == 7:
  print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
  
elif A-B+C+D == 7:
  print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
  
elif A-B+C-D == 7:
  print(str(A) + "-" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
  
elif A-B-C+D == 7:
  print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
  
else:
  print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")

Measured memory_bytes: 9292
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC targett("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(ll i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define inf 2e18
#define h_p 1110111110111;
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//_______________________________________________________________________________
ll power(ll a,ll b)
{
   ll ans=1;
   while(b>0)
   {
       if(b%2)
       {
           ans=(ans*a);
       }
       a=(a*a);
       b=b/2;
   }
   return ans;
}
int main()
{
       ll curr = 0;
       vector<ll> pp;
       map<ll,ll> mp;
       while(1)
       {
              mp[power(curr,5)] = curr;
              pp.pb(power(curr,5));
              if(power(curr,5) > 1e15){break;}
              curr++;
       }
       ll x;
       cin>>x;
       fri(i,0,pp.size())
       {
              fri(j,i,pp.size())
              {
                     if((pp[i] + pp[j]) == x)
                     {
                            cout<<mp[pp[i]]<<" "<<-mp[pp[j]]<<endl;
                            return 0;
                     }
                     if((pp[j] - pp[i]) == x)
                     {
                            cout<<mp[pp[j]]<<" "<<mp[pp[i]]<<endl;
                            return 0;
                     }
              }
       }
}


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

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

  ll res = 0;
  int count = 0;
  for (int i = 0; i < s.length(); i++)
  {
    if (s[i] == 'W')
    {
      res += i - count;
      count++;
    }
  }

  cout << res << endl;
}

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

using namespace std;


int main(){
    int n,k;
    int temp;
    int mask = 0;
    scanf("%d",&n);
    scanf("%d",&k);

    for(int i = 0;i < k;i++){
        scanf("%d",&temp);
        mask |= (1 << temp);
    }

    for(int i = 0; i < (1 << n);i++){
        if((i & mask) == mask){
            printf("%d:",i);
            for(int j = 0;j < n;j++){
                if( i&(1<<j) ) printf(" %d",j);
            }
            printf("\n");
        } 
    }
    
    return 0;   
}



Measured memory_bytes: 3236
def solve():
    N, K, S = map(int, input().split())
    if S == 10 ** 9:
        ans = [S] * K + [1] * (N-K)
    else:
        ans = [S] * K + [S+1] * (N-K)

    print(*ans)
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 46148
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

vector<string> word = {"dream","dreamer","erase","eraser"};
string s;

bool dfs(int n){
    if(n == s.size()) return true;
    for(string wo : word){
        if(s.substr(n,wo.size()) == wo) if(dfs(n + wo.size())) return true;
    }
    return false;
}

int main(){

    cin >> s;
    dfs(0) ? cyes : cno;
    
    return 0;   
}


Measured memory_bytes: 2688
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
string s;
int main() {
	cin >> s;
	int ret = s.size() + (s[0] == s.back() ? 1 : 0);
	cout << (ret % 2 == 1 ? "First" : "Second") << endl;
	return 0;
}

Measured memory_bytes: 512
a, b, c, d, e = 5.times.map { gets.to_i }

def upto10s(x)
  (x * 0.1).ceil * 10
end

all = [a, b, c, d, e]
last = all.max_by { |x| upto10s(x) - x }
sum = all.map { |x| upto10s(x) }.inject(:+)
puts (sum - upto10s(last) + last).to_i


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#define debug(x) std::cerr<<"L: "<<__LINE__<<" "<<__FUNCTION__<<"() Var: "<<#x<<" Val: "<<x<<"\n"
#else
#define debug(x)
#endif
typedef long long ll;
const int inf = 0x7f7f7f7f;

inline void gettime() {
	debug(clock());
}
inline int read() {
	static char c;
	static int x;
	int flag = 1;
	while (c = getchar(), !isdigit(c)) if (c == '-') flag = -1;
	x = c - '0';
	while (c = getchar(), isdigit(c))x = (x << 1) + (x << 3) + c - '0';
	return x * flag;
}
inline char achar() {
	static char c;
	while (c = getchar(), !isalpha(c));
	return c;
}

int main() {
#ifndef ONLINE_JUDGE
	std::atexit(gettime);
#endif

	double a = read(), b = read();
	printf("%.0lf\n", std::ceil((a - 1) / (b - 1)));
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define double long double
using namespace std;
typedef pair<int, int>P;
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
//繰り返し二乗法
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
//xCy
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int f(int x) {
	int ans = 1;
	for (int i = 1; i <= x; i++) {
		ans *= i;
		ans %= mod;
	}
	return ans;
}
struct edge { int to, cost; };
signed main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22)puts("bust");
	else puts("win");
	ggr
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define n_l '\n'
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: "; cerr << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cerr << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cerr << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cerr << endl
#define run(a, b) cerr << fixed << setprecision(6) << (double) (b - a) / (double) (CLOCKS_PER_SEC) << " s" << endl;
#define ll long long
#define ld long double
#define INF (1e18L + 5)
#define MOD (ll)(1e9 + 7)

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, r;
    cin >> n >> r;
    cout << max(0, n - (2 * r)) << endl;
    return 0;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

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

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    if(s[0] == 'A'){
        int C = 0;
        for(int i = 1; i < s.size(); ++i){
            if(i >= 2 && i <= s.size() - 2 && s[i] == 'C') C++;
            else if(s[i] < 'a' || 'z' < s[i]){
                cout << "WA\n";
                return 0;
            }
        }
        if(C == 1) cout << "AC\n";
        else cout << "WA\n";
    }
    else cout << "WA\n";
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n, m = map(int, input().split())
al = [int(i) for i in input().split()]
d, t = defaultdict(int), 0
for i in range(n):
    t = (al[i] + t) % m
    d[t] += 1
ans = 0
d[0] += 1
for k, v in d.items():
    ans += v * (v - 1) // 2
print(ans) 

Measured memory_bytes: 14636
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> H(N);
    rep(i, N) { cin >> H[i]; }

    vector<vector<ll>> G(N, vector<ll>());
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll cnt = 0;

    rep(i, N) {
        bool judge = true;
        for (auto g : G[i]) {
            if (H[i] <= H[g]) {
                judge = false;
                break;
            }
        }
        if (judge)
            cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 9808
#include <stdio.h>
int main(void){
    int n,q,a[100000]={0},i;
    char s[100001];
    scanf("%d %d",&n,&q);
    scanf("%s",s);
    for(i=1;i<n;i++){
        if(s[i-1]=='A' && s[i]=='C') a[i] = a[i-1]+1;
        else a[i]=a[i-1];
    }
    for(i=0;i<q;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        printf("%d\n",a[y-1]-a[x-1]);
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////
bool comp(const pair<string,int> &a,const pair<string,int> &b)
{
    return(a.first<b.first || (a.first==b.first && a.second>b.second));
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    int ch[101];
     int n;
     cin>>n;
     vector<pair<string,int>> v;
     map<string,int> m;
     REP(i,n)
     {
         string j;
         int x;
         cin>>j>>x;
         v.push_back({j,x});
         ch[x]=i+1;
     }
     sort(v.begin(),v.end(),comp);
    for(auto i:v)
    {
        cout<<ch[i.second]<<"\n";
    }
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    static Scanner kbd = new Scanner(System.in);
    public static void main(String[] args){
	solve();
    }

    static void solve(){
	boolean[] x = new boolean[1001];
	boolean[] z = new boolean[1001];
	int[] y = new int[1001];
	int term = 0, i=0;
	String a, b="";

	while(kbd.hasNext()){
	    String s = kbd.nextLine();
	    if(s.equals("")){
		term = 1;
	    }
	    else{
		i=0;
		while(!s.substring(i, i+1).equals(",")){
		    a = s.substring(i, i+1);
		    b += a;
		    i++;
		}
		int p = Integer.parseInt(b);
		b = "";
		if(term==0){
		    x[p] = true;
		    y[p] ++;
		}
		else{
		    z[p] = true;
		    y[p] ++;
		}
	    }
	}

	for(i=0; i<x.length; i++){
	    if(x[i] && z[i])
		System.out.println(i+" "+y[i]);
	}
    }
}

Measured memory_bytes: 17176
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<string> vs;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 2e9+7;

int main() {
    int n, i;
    cin >> n >> i;
    cout << n - i + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        s: chars
    }
    if s[0] == s[1] {
        println!("1 2");
        return;
    }
    let n = s.len();
    for i in 2..n {
        if s[i] == s[i - 1] {
            println!("{} {}", i, i + 1);
            return;
        } else if  s[i] == s[i - 2] {
            println!("{} {}", i - 1, i + 1);
            return;
        }
    }
    println!("-1 -1");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int a,b,n,minn=1000000;

inline int sum(int k)
{
	int m=0;
	while(k>0)
	{
		m+=k%10;
		k/=10;
	}
	return m;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n/2;i++)
		minn=min(minn,sum(i)+sum(n-i));
		printf("%d\n",minn);
		return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int n,a[100010];
bool cmp(int a,int b) { return a>b; }
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,cmp);
	for (int i=1,x;i<=n;i++) if (a[i+1]<i+1&&a[i]>=i)
	{
		x=0;
		while (a[i+x+1]==i) x++;
		if ((a[i]-i)%2==0&&x%2==0) printf("Second\n"); else printf("First\n");
	}
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
main()
{
	string s;
	cin>>s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3])
	{
		cout<<"Bad"<<"\n";
	}
	else
	{
		cout<<"Good"<<"\n";
	}
}


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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int M;

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

  cout << (24 - M) + 24 << endl;

  return 0;
}


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

red = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[1], reverse=True)
blue = sorted([list(map(int, input().split())) for i in range(N)])
ans = 0

for b_x, b_y in blue:
    for r_x, r_y in red:
        if b_x > r_x and b_y > r_y:
            red.remove([r_x, r_y])
            ans += 1
            break

print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

const int INF = 1 << 30;
const uint64_t MOD = 1000000000 + 7;

void couting_sort(vector<int> &a, vector<int> &b, int k)
{
	vector<int> c(k + 1);
	
	for (int i = 0; i < a.size(); i++)
	{
		c.at(a.at(i))++;
	}

	for (int i = 1; i <= k; i++)
	{
		c.at(i) += c.at(i - 1);
	}


	for (int i = a.size() - 1; i >= 0; i--)
	{
		b.at(c.at(a.at(i)) - 1) = a.at(i);
		c.at(a.at(i))--;	
	}
}

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

	vector<int> a(n);
	vector<int> b(n);

	int k = -INF;
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a.at(i));

		k = max(k, a.at(i));
	}

	couting_sort(a, b, k);

	for (int i = 0; i < n; i++)
	{
		cout << (i == 0 ? "" : " ") << b.at(i);
	}


	cout << endl;
}


Measured memory_bytes: 18400
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt();

        int[] c = new int[12];
        c[0] = 1;
        c[1] = (int) Math.pow(6, 1);
        c[2] = (int) Math.pow(9, 1);
        c[3] = (int) Math.pow(6, 2);
        c[4] = (int) Math.pow(9, 2);
        c[5] = (int) Math.pow(6, 3);
        c[6] = (int) Math.pow(9, 3);
        c[7] = (int) Math.pow(6, 4);
        c[8] = (int) Math.pow(9, 4);
        c[9] = (int) Math.pow(6, 5);
        c[10] = (int) Math.pow(9, 5);
        c[11] = (int) Math.pow(6, 6);

        int[] t = new int[n + 1];
        for (int i = 0; i <= n; i++) {
            t[i] = 100000000;
        }
        t[0] = 0;

        for (int i = 0; i < 12; i++) {
            for (int j = c[i]; j <= n; j++) {
                t[j] = Math.min(t[j], t[j - c[i]] + 1);
            }
        }

        System.out.println(t[n]);
    }
}


Measured memory_bytes: 25940
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))

    max_L = max(L)
    sum_L = sum(L)
    if max_L < sum_L - max_L:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

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

  ll n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];

  ll ans = 0;
  rep(i, 0, n){
    ll sum = 0;
    for(ll j = 0; j <= i; j++) sum += a[j];
    for(ll j = i; j < n; j++) sum += b[j];
    chmax(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

unordered_map<ll, ll> mp;
ll n;
vector<ll> a;

void solve() {
    ll d[n];
    d[0] = abs(a[0]);
    ll summ = abs(a[0]);
    repone(i, n - 1) {
        d[i] = abs(a[i] - a[i - 1]);
        summ += d[i];
    }
    summ += abs(a[n - 1]);
    rep(i, n) {
        if (i == 0) {
            if (a[i] * a[i + 1] < 0) {
                cout << summ - 2 * abs(a[i]) << endl;
            } else {
                if (abs(a[i]) > abs(a[i + 1])) {
                    cout << summ - 2 * (abs(a[i]) - abs(a[i + 1])) << endl;
                } else {
                    cout << summ << endl;
                }
            }
        } else if (i == n - 1) {
            if (a[i - 1] * a[i] < 0) {
                cout << summ - 2 * abs(a[i]) << endl;
            } else {
                if (abs(a[i - 1]) < abs(a[i])) {
                    cout << summ - 2 * (abs(a[i]) - abs(a[i - 1])) << endl;
                } else {
                    cout << summ << endl;
                }
            }
        } else {
            if ((a[i + 1] - a[i]) * (a[i - 1] - a[i]) > 0) {
                cout << summ - 2 * min(d[i], d[i + 1]) << endl;
            } else {
                cout << summ << endl;
            }
        }
    }
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = unordered_map<ll, ll>();
#pragma clang diagnostic pop
#endif
        cin >> n;
        a.resize(n);
        rep(i, n)cin >> a[i];

        solve();

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
//#define temo

using namespace std;
const int N = 1e5 + 5;

ll n, a[N], ans, ans1, ans2;

int main()
{
    cin>>n;
    for (int i = 1; i <= n; i++)
        cin>>a[i];
    sort (a + 1, a + n + 1);
    if (n % 2 == 0){
        for (int i = 1; i < n / 2; i++)
            ans -= 2 * a[i];
        ans -= a[n / 2];
        ans += a[n / 2 + 1];
        for (int i = n / 2 + 2; i <= n; i++)
            ans += 2 * a[i];
        cout<<ans<<endl;
        return 0;
    }
    for (int i = 1; i < n / 2; i++)
        ans1 -= 2 * a[i];
    ans1 -= a[n / 2];
    ans1 -= a[n / 2 + 1];
    for (int i = n / 2 + 2; i <= n; i++)
        ans1 += 2 * a[i];


    for (int i = 1; i <= n / 2; i++)
        ans2 -= 2 * a[i];
    ans2 += a[n / 2 + 1];
    ans2 += a[n / 2 + 2];
    for (int i = n / 2 + 3; i <= n; i++)
        ans2 += 2 * a[i];
    ans = max (ans1, ans2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/
template <class Begin, class End>
struct span {
    using value_type=typename Begin::value_type;

    Begin begin_;
    End end_;

    span(Begin begin__, End end__)
        :begin_(begin__), end_(end__) {}

    template<class T>
    span(T const&v,i64 l,i64 r)
        : span(std::begin(v) + l, std::begin(v) + r) {}

    auto begin() { return begin_; }
    auto end() { return end_; }
    auto begin() const { return begin_; }
    auto end() const { return end_; }
};
template <class T>
auto make_span(T const& v, usize l, usize r) {
    using iterator_type = std::decay_t<decltype(v.begin())>;
    return span<iterator_type, iterator_type>(v, l, r);
}
int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    std::cin >> n;
    vec<std::pair<usize, usize>> a(n);
    for (usize i=0; i<n; i++) {
        usize x;
        std::cin >> x;
        a.at(i) = {x, i};
    }
    std::sort(ALL(a));

    usize ans = 0;
    for (usize i=0, j=0; i<n; i=j) {
        i32 even_index_surplus = 0;
        for (j=i; j<n && a.at(i).first==a.at(j).first; j++) {
            even_index_surplus += j%2==0;
            even_index_surplus -= a.at(j).second%2==0;
        }
        ans += std::abs(even_index_surplus);
    }
    assert(ans%2==0);
    std::cout << ans/2 << '\n';
}


Measured memory_bytes: 1792
"use strict"

const main = arg => {
  arg = arg.trim().split("\n");
  const N = parseInt(arg[0]);
  const s = arg[1].split(" ").map(n=>parseInt(n));

  const points = [0, ...s, 0];
  const diff   = [];
  const answer = [];

  points.forEach((p, i, self) => {
    if (i < self.length - 1) diff.push(self[i + 1] - self[i]);
  });

  const sum = diff.map(n => Math.abs(n)).reduce((a, b) => a + b);

  for(let i=1; i<points.length - 1; i++) {
    const skipped = Math.abs(points[i - 1] - points[i + 1]);
    const stepped = Math.abs(points[i - 1] - points[i]) + Math.abs(points[i] - points[i + 1]);

    const changed = skipped - stepped;

    answer.push(sum + changed);
  }

  console.log(answer.join("\n"));
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 35280
#include <iostream>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int vis[100005];
#define rep(i,a,b) for(int i=a;i<=b;i++)
int main(int argc, char** argv) {
	int n;
	cin>>n;
	int a=0;
	rep(i,1,n)
	{
		int x;
		cin>>x;
		if(vis[x])a++;
		vis[x]=1;
	}
	if(a%2==0)
	{
		cout<<n-a;
	}
	else cout<<n-a-1;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    // 整数の入力
    int n;
    int largenum=10000000;
    vector<int> charcounts(26,largenum);
    cin >> n;
    string str;
    for(int i=0;i<n;i++){
        vector<int> tmpcharcounts(26,0);
        cin >> str;
        for(int j=0;j<str.size();j++)
            tmpcharcounts[str[j]-'a']++;
        for(int c=0;c<26;c++)
            if(tmpcharcounts[c]<charcounts[c])
                charcounts[c] = tmpcharcounts[c];
    }
    for(int c=0;c<26;c++)
        if(charcounts[c]<largenum)
            for(int i=0;i<charcounts[c];i++)
                cout << char('a' + c);
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll _() {
	ll x=0,f=1; char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())
		if(ch=='-')f=-f;
	for(;ch>='0'&&ch<='9';ch=getchar())
		x=x*10+ch-'0';
	return x*f;
}
#define _ _()
int main() {
	int n=_,h=_,w=_;
	cout<<(n-h+1)*(n-w+1);
}


Measured memory_bytes: 256
W, H, n = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(n)]

min_x = 0
max_x = W
min_y = 0
max_y = H
for x, y, a in query:
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        max_x = min(max_x, x)
    elif a == 3:
        min_y = max(min_y, y)
    else:
        max_y = min(max_y, y)

print(max(0, (max_x - min_x)) * max(0, (max_y - min_y)))

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

#define int long long
#define all(v) (v).begin(), (v).end()
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int INF = 1e18;

int A, B, Q;
vector<int> s, t;

int solve(int x) {
  // Right, Leftはxより右にあるか左にあるか
  int sRight = abs(*lower_bound(all(s), x));
  int sLeft = abs(*(upper_bound(all(s), x) - 1));
  int tRight = abs(*lower_bound(all(t), x));
  int tLeft = abs(*(upper_bound(all(t), x) - 1));

  int ret = INF;

  // (s, t) -> x -> (t, s)
  if (sLeft != INF and tLeft != INF) {
    chmin(ret, abs(x - min(sLeft, tLeft)));
  } 

  // s -> x -> t {
  if (sLeft != INF and tRight != INF) {
    chmin(ret, min(abs(x - sLeft), abs(x - tRight)) + abs(sLeft - tRight));
  }

  // t -> x -> s {
  if (tLeft != INF and sRight != INF) {
    chmin(ret, min(abs(x - tLeft), abs(x - sRight)) + abs(tLeft - sRight));
  }

  // x -> (s, t) -> (t, s)
  if (sRight != INF and tRight != INF) {
    chmin(ret, abs(max(sRight, tRight) - x));
  }

  return ret;
}

signed main() {
  cin >> A >> B >> Q;
  s.resize(A);
  t.resize(B);
  for (int i = 0; i < A; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> t[i];
  }

  // 番兵を設置すると楽に参照エラーを防げる
  s.push_back(INF);
  s.push_back(-INF);
  t.push_back(INF);
  t.push_back(-INF);
  sort(all(t));
  sort(all(s));

  while (Q--) {
    int x;
    cin >> x;
    int ans = solve(x);
    cout << solve(x) << endl;
  }

  return 0;
}

Measured memory_bytes: 2912
// Problem : A - AtCoder *** Contest
// Contest : AtCoder - AtCoder Beginner Contest 048
// URL : https://atcoder.jp/contests/abc048/tasks/abc048_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

#define spc ' '
#define endl '\n'

using namespace std;


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s, ans = "";
	while(cin >> s){
	    ans += s[0];
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}


int main() {
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    a--;b--;c--;d--;
    string s;
    cin >> s;

    if(d<c){
        int x = 1;
        if(s[b-1]=='.')x = 2;
        srep(i,b+1,d+2){
            if(s[i]=='#'){
                x = 0;
            }else{
                x++;
                if(x==3){
                    break;
                }
            }
        }
        if(x!=3){
            cout << "No" << endl;
            return 0;
        }
    }

    srep(i,a,c){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    srep(i,b,d){
        if(s[i]=='#'&&s[i+1]=='#'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
 
 


Measured memory_bytes: 640
# 参考 http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2973729#1

def ans(sr, sc, tbl):
	if 4 in sr: return 'C'
	if 4 in sc: return 'B'
	if 1 in sr: return 'F' if tbl[sr.index(1)][sc.index(2)] == 1 else 'D'
	if 1 in sc: return 'E' if tbl[sr.index(2)][sc.index(1)] == 1 else 'G'
	return 'A'
	
tbl = [[] for i in range(8)]
sr, sc = [0]*8, [0]*8
while True:
	for r in range(8): tbl[r] = list(map(int, input()))
	# 行の総数
	for i in range(8): sr[i] = sum(tbl[i])
	# 列の総数
	for i in range(8): sc[i] = sum([tbl[r][i] for r in range(8)])
	print(ans(sr, sc, tbl))
	try: input()
	except: break


Measured memory_bytes: 5608
#B Buffet
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
s=0
tmp=0
for i in range(n-1):
    if a[i]+1==a[i+1]:
        s+=c[a[i]-1]
s+=sum(b)
print(s)

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

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

int main() {
  int k;
  int64_t sum =0;
  cin >> k;
  for (int i = 1; i <= k; i++) {
    for (int j = 1; j <= k; j++) {
      for (int l = 1; l <= k; l++) {
        sum += gcd(i,gcd(j,l));
      }
    }
  }
  cout << sum << endl;
}

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

#define BR "\n"

int main() {
  string S, T;
  cin >> S >> T;
  S = S + S;
  
  string ans = "No";
  for(int i = 0; i < T.size(); i++) {
    bool check = true;
	for(int j = 0; j < T.size(); j++) {
      if (S[i + j] != T[j]) {
        check = false;
        break;
      }
	}
    if (check) {
      ans = "Yes";
    }
  }

  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int a[101];
	int color[8]={0},variable=0;
	scan(N);
	rep(i,N){
		scan(a[i]);
		if(a[i]<3200) color[a[i]/400]=1;
		else variable++;
	}
	int colornummin=0;
	rep(i,8){
		colornummin+=color[i];
	}
	printf("%d %d\n",max(1,colornummin),colornummin+variable);


	return 0;
}


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;

int main(){
  int n;
  cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  int cnt = 0;
  for(int i = 1; i<n; i++){
    if(a[i-1]==a[i]) {
      cnt++;
      i++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
        static void Main(string[] args)
    	{
            string s = Console.ReadLine();
            char c = '0';
            int count = 0;
            int ans = 0;
            for (int i=0; i<s.Length; i++)
            {
                if (c != s[i])
                {
                    if (count % 3 == 2)
                    {
                        ans += 2 * (count + 1) / 3;
                        i++;
                        if (i == s.Length)
                        {
                            Console.WriteLine(ans);
                            return;
                        }
                        c = s[i];
                        count = 1;
                    }
                    else
                    {
                        ans += 2 * count / 3 + count % 3;
                        c = s[i];
                        count = 1;
                    }
                    
                }
                else count ++;
            }
            if (count % 3 == 2) ans += 2 * (count + 1) / 3 - 1;
            else ans += 2 * count / 3 + count % 3;
            Console.WriteLine(ans);
        }
    
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 13140
def solve():
    import sys
    file_input = sys.stdin
    
    N, M, Q = map(int, file_input.readline().split())
    
    student = list(range(N))
    exemption = [1] * N
    pos = 0
    for a in map(int, file_input.readline().split()):
        if a % 2:
            pos = (pos - a) % len(student)
        else:
            pos = (pos + a) % len(student)
        s = student[pos]
        exemption[s] = 0
        del student[pos]
    
    question = map(int, file_input.readline().split())
    print(*map(lambda x:exemption[x], question), sep = '\n')

solve()


Measured memory_bytes: 28820
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;


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

	cin >> N;
	vector<long double>v(N);
	for (auto &i : v)cin >> i;
	sort(v.begin(), v.end());
	while (v.size() > 1) {
		v[0] += v[1];
		v[0] /= 2;
		swap(v[1], v.back());
		v.pop_back();
		sort(v.begin(), v.end());
	}
	cout <<setprecision(20)<< v[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size() 

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1;      
    x = x % p;  
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
	ll n,i,j,k,x,y,t,m;

	cin >> n >> m;
	cout<<(n*(n-1))/2+(m*(m-1))/2<<endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::ascii::AsciiExt;

fn toggle_cases(c:char) -> char {
    if c.is_uppercase() {
        c.to_ascii_lowercase()
    } else {
        c.to_ascii_uppercase()
    }
}

fn main() {
    let stdin = stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let ans:String = buf.chars().map(|s| toggle_cases(s)).collect();
    print!("{}", ans);
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int N;
    cin >> N;
    int a = 1;
    rep(i, 20) {
        if (N == a) {
            cout << "No" << endl;
            return 0;
        }
        a *= 2;
    }
    if (N % 2 == 1) {
        cout << "Yes" << endl;
        rep(i, N / 2) {
            int a = 2 * i + 2;
            int b = 2 * i + 3;
            cout << 1 << " " << a << endl;
            cout << a << " " << b << endl;
            cout << 1 << " " << b + N << endl;
            cout << b + N << " " << a + N << endl;
        }
        cout << 3 << " " << 1 + N << endl;
    } else {
        cout << "Yes" << endl;
        rep(i, (N - 1) / 2) {
            int a = 2 * i + 2;
            int b = 2 * i + 3;
            cout << 1 << " " << a << endl;
            cout << a << " " << b << endl;
            cout << 1 << " " << b + N << endl;
            cout << b + N << " " << a + N << endl;
        }
        cout << 3 << " " << 1 + N << endl;
        //Nと2Nの配置
        int n2 = N & -N;
        int n1 = N - n2;
        cout << n1 << " " << N << endl;
        cout << n2 + 1 + N << " " << 2 * N << endl;
    }
    return 0;
}


Measured memory_bytes: 2304
Scanf.scanf "%d %d" (fun n k ->
    let h = Array.init n (fun _ -> Scanf.scanf " %d" (fun h -> h)) in
    Array.sort compare h;
    let rec loop i acc =
        if i < 0 then acc else loop (i - 1) (acc + h.(i))
    in
    let r = loop (max (-1) (n - 1 - k)) 0 in
    Printf.printf "%d\n" r
)

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

int main(void) {
	int n, sum, max, min, ave,a,total;
	int i,num;

	for (;;) {
		sum = 0;
		min = 1000;
		max = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			cin >> a;
			sum += a;
			if (max < a) {
				max = a;
			}
			if (min > a) {
				min = a;
			}

		}

		total = sum - max - min;
		num= n - 2;

		ave = total / num;

		cout << ave << endl;

	}

	return 0;
}

Measured memory_bytes: 1160