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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            var s = Console.ReadLine();
            var t = Console.ReadLine();

            var converter = new List<char[]>();

            for(int i = 0; i < s.Length; i++) {
                converter.Add(new char[] { s[i], t[i] });
            }

            var a = converter.Select(x => x[0]).ToList();
            var b = converter.Select(x => x[1]).ToList();
            var flag = false;
            var aa = new Dictionary<char, char>();
            var bb = new Dictionary<char, char>();

            for (int i = 0; i < a.Count; i++) {
                if (aa.ContainsKey(a[i])) {
                    if (aa[a[i]] != b[i]) {
                        flag = true;
                    }
                } else {
                    aa.Add(a[i], b[i]);
                }

                if (bb.ContainsKey(b[i])) {
                    if (bb[b[i]] != a[i]) {
                        flag = true;
                    }
                } else {
                    bb.Add(b[i], a[i]);
                }
            }

            Console.WriteLine(flag ? "No" : "Yes");

            Console.Out.Flush();
        }
    }
}


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

int main(){
   int n,c=0,max=0;
   long long h=0;
   cin>>n; 
   for(int i=0;i<n;i++){
	   long long h1;
	   cin>>h1;
	   if(h1>h){
		   if(max<c){
			   max=c;
		   }
		   c=0;
	   }else{

		   c++;
	   }
	   h=h1;
   }
   if(max<c){
			   max=c;
		   }
   cout<<max<<endl;
   
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(int i=a;i<=b;++i)
#define read(n)  scanf("%d",&n)
#define ll long long
int main()
{
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int ans=h2*60-h1*60+m2-m1;
	cout<<max(0,ans-k);
	return 0;
} 

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer n = Integer.parseInt(scanner.next());

        List<Integer> listA = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            listA.add(Integer.parseInt(scanner.next()));
        }
        ArrayList<Integer> listB = new ArrayList<>(listA);
        Collections.sort(listB);

        int max = listB.get(listB.size()-1);
        int max2 = listB.get(listB.size()-2);

        for(int i = 0; i< listA.size(); i++) {
            if(max != listA.get(i)) {
                System.out.println(max);
            } else {
                System.out.println(max2);
            }
        }

    }
}


Measured memory_bytes: 74468
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//最大化問題最小化問題
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll K;
    cin >> K;



    //本文
    REP(i,K){
        cout << "ACL";
    }
    //出力
    //cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x;
	cin>>x;
	for(int i = sqrt(x);i<=x;i++)
	{
		ll ans = i*(i+1)/2;
		if(ans>=x)
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
/*
    Author: FireDrake99
    Time created: 2019-10-19-19.09
*/

#include<bits/stdc++.h>
using namespace std;

//------------Constants----------------
#define ll long long int
//------------Variables----------------
string s,ans;
int n;
//------------Functions----------------

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//------------Input--------------------
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    cin >> n;
    cin >> s;
//------------Work---------------------
    for (int i=0; i<n; i++){
        ans+=s[i];
        while (s[i]==s[i+1]) i++;
    }
    cout << ans.length();
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  string s;
  cin >> s;
  rep(i,s.size()) cout << "x";
  cout << endl;
}

Measured memory_bytes: 3588
from itertools import  product
n,m=map(int,input().split())
s=[]
for i in range(m):
    s.append(list(map(int,input().split())))
p=list(map(int,input().split()))
ans=0

for z in product((0, 1), repeat=n):
    righton_count=0
    for i in range(m):
        switc_on_count=0
        for j in range(1,s[i][0]+1):
            if z[s[i][j]-1]==1:              
                switc_on_count+=1
        if switc_on_count%2==p[i]:
            righton_count+=1
    if righton_count==m:
        ans+=1



print(ans)

Measured memory_bytes: 42224
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'
 
int main()
{
   // #ifndef ONLINE_JUDGE
   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   // #endif
    string s;
    cin>>s;
    int n=sz(s);
    int flag=0;
    ffor(i,1,n)
    {
        if(s[i]!=s[0]) flag=1;
    }
    if(flag) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    if N % 2:
        print(0)
    else:
        ans = 0
        i = 1
        while N >= 5 ** i:
            ans += (N // 5 ** i) // 2
            i += 1
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int H,W,i,u;
    while(1){
        scanf("%d %d",&H, &W);
        if(H==0 && W==0) break;
        
        for(i=0;i<H;i++){
            for(u=0;u<W;u++){
                if(i==0 || i==H-1 || u==0 || u==W-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, M, K;
    cin >> N >> M >> K;

    rep(i, N+1) {
        rep (j, M+1) {
            if ((N-i)*j+i*(M-j) == K) {
                Yes;
                return 0;
            }
        }
    }

    No;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    string s;
    cin >> s;
    int mod = 0;
    for (char c: s) mod = (mod + c - '0') % 9;
    if (mod == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 3708
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, parser) => {
        $next
    };

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

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

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        x: usize,
    }
    println!("{}", 1000 * (x / 500) + 5 * ((x % 500) / 5));
}


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


def solve(A: int, B: float):
    B *= 1000
    C = int(B)
    print(A * C // 1000)

    # Bbig = int(B)
    # # print(Bbig)
    # Bsmall = int((B - Bbig) * 10)
    # # print(Bsmall)
    # Bsmall2 = int((B - Bbig) * 100) - Bsmall * 10
    # # print(Bsmall2)
    # Abig = A * Bbig * 100
    # # print(Abig)
    # Asmall = (A * Bsmall) * 10
    # # print(Asmall)
    # Asmall2 = (A * Bsmall2)
    # # print(Asmall2)
    # print((Abig + Asmall + Asmall2) // 100)
    return


# Generated by 1.1.7.1 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()
    A = int(next(tokens))  # type: int
    B = float(next(tokens))  # type: float
    solve(A, B)

if __name__ == '__main__':
    main()

Measured memory_bytes: 61828
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    mochis = list(map(int, inputs))
    mochis.sort(reverse=True)
    count = 0
    prev_mochi = -1
    for m in mochis:
        if prev_mochi == -1 or prev_mochi > m:
            count += 1
        prev_mochi = m
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int h,w;
  cin>>h>>w;
  int a[h][w];
  rep(i,0,h){
    rep(j,0,w){
      cin>>a[i][j];
    }
  }
  int b[h*w][4];
  int ans=0;
  rep(i,0,h){
    rep(j,0,w-1){
      if(a[i][j]%2!=0){
        a[i][j]--;
        a[i][j+1]++;
        b[ans][0]=i;
        b[ans][1]=j;
        b[ans][2]=i;
        b[ans][3]=j+1;
        ans++;
      }
    }
  }
  rep(i,0,h-1){
    if(a[i][w-1]%2!=0){
      a[i][w-1]--;
      a[i+1][w-1]++;
      b[ans][0]=i;
      b[ans][1]=w-1;
      b[ans][2]=i+1;
      b[ans][3]=w-1;
      ans++;
    }
  }
  cout<<ans<<endl;
  rep(i,0,ans){
    cout<<b[i][0]+1<<" "<<b[i][1]+1<<" "<<b[i][2]+1<<" "<<b[i][3]+1<<endl;
  }
}

Measured memory_bytes: 6656
#include <iostream>
#include <string>

using namespace std;

int main(){

  int q;

  cin >> q;


  for(int k = 0; k < q; k++){
    string a, b;
    cin >> a >> b;
    int dp[a.size()][b.size()] = {};
    //初期設定
    if(a[0] == b[0]){
      dp[0][0] = 1;
    }
    for(int i = 1; i < a.size(); i++){
      if(a[i] == b[0] || dp[i-1][0] == 1){
        dp[i][0] = 1;
      }
    }
    for(int j = 1; j < b.size(); j++){
      if(a[0] == b[j] || dp[0][j-1] == 1){
        dp[0][j] = 1;
      }
    }
    for(int i = 1; i < a.size(); i++){
      for(int j = 1; j < b.size(); j++){
        if(a[i] == b[j]){
          if(dp[i-1][j-1] >= dp[i-1][j] && dp[i-1][j-1] >= dp[i][j-1]){
            dp[i][j] = dp[i-1][j-1]+1;

          }
          else{
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
          }
        }
        else{
          dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
      }
    }
    cout << dp[a.size()-1][b.size()-1] << "\n";
  }

  return 0;
}



Measured memory_bytes: 7012
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

class UnionFind{
public:
    vector<int> par;
    vector<int> rank;
    vector<int> sz;
    int uf_size;

    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        sz.resize(n);
        uf_size = n;
        for(int i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }

    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }

    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(rank[x] < rank[y]) swap(x, y);
        if(rank[x] == rank[y]) rank[x]++;
        uf_size--;
        par[y] = x;
        sz[x] = sz[x] + sz[y];
        return true;
    }

    int size(int x){
        return sz[find(x)];
    }
};

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

    int n, q; cin>>n>>q;
    UnionFind uf(n);

    while(q--){
        int c, x, y; cin>>c>>x>>y;
        if(c == 0) uf.unite(x, y);
        else cout << uf.same(x, y) << endl;
    }

    return 0;
}


Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ch[26];
    char c='A';
    /*for(int i=0;i<26;i++)
    {
        ch[i]=c;
        c++;
        cout<<ch[i]<<" ";
    }*/
    for(int i=0;i<s.size();i++)
    {
        int k=(s[i]+n);
        if(k<=90)
            s[i]=s[i]+n;
        else
        {
            s[i]=s[i]+n-26;
        }
        cout<<s[i];
    }
}


Measured memory_bytes: 256
(let ((n (read)))
  (loop :for i from 1 to n
        :when (oddp i) :collect (read) :into o
        :when (evenp i) :collect (read) :into e
        :finally  (when (evenp n)
                    (rotatef o e))
        (format t "~{~A ~}~{~A ~}" (reverse o) e)))

Measured memory_bytes: 71268
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
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, 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") }; }

fn main() {
    input! {
        s: chars,
    }

    let mut ans = 0;
    let mut sum = 0;
    let acgt = vec!['A', 'C', 'G', 'T'];
    for &c in s.iter() {
        if acgt.contains(&c) {
            sum += 1;
        } else {
            ans = std::cmp::max(ans, sum);
            sum = 0;
        }
    }
    ans = std::cmp::max(ans, sum);
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define int int64_t
using namespace std;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> v(n);
	int sum = 0;
	for (int i=0; i<n; ++i){
		 cin >> v[i];
		sum += v[i];
	}
	int crt = 0,maxi = sum;
	for (int i=0; i<n; ++i){
		crt += v[i];
		sum -= v[i];
		maxi = min(maxi,abs(crt-sum));
	}
	cout << maxi;
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}

ll N,M;
const ll limit=28;

ll a[limit];
ll b[limit];

 bool G[limit][limit];



ll dfs(ll v,bool visited[limit]){//vは現在位置、visitedはvまでどこを通ってきたか記録？
 bool ALL=true;
rep(i,N){ 
if(visited[i]==false){
ALL=false;
}
}
if(ALL){
  return 1;//全ての点を通っていたら１を足す
}

ll ret=0;

rep(i,N){
if(G[v][i]==true&&visited[i]==false){
  
  visited[i]=true;
  ret+=dfs(i,visited);//vから次のステップへのdfs生成？？？
  visited[i]=false;//visited[i]=trueを積んだdfsを生成した後falseに戻すイメージ
}
}
return ret;//dfs生成？？？
}


    
int main(){
  cin>>N>>M;

  
  rep(i,M){
    cin>>a[i]>>b[i];
    G[a[i]-1][b[i]-1]=G[b[i]-1][a[i]-1]=true;
  }
  bool visited[limit];
rep(i,N){
  visited[i]=false;
  
}

  visited[0]=true;
  
  cout<<dfs(0,visited)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
 
using namespace std;
 
struct team{
    int tID;
    int pID;        //問題ID
    vector<int> p;  //誤答数
    int ansnum;     //正答数
    int time;       //時間
	int place;
 
    bool operator<( const team& right ) const {
        return ( ansnum == right.ansnum ? 
            (time == right.time ? tID < right.tID : time > right.time) 
			: ansnum < right.ansnum );
    }
	bool operator==( const team& right ) const {
        return ( ansnum == right.ansnum ? 
            time == right.time : false );
    }
};
 
int main(void){
  //  FILE* fp_in = freopen("data.txt", "r", stdin);
 
    while(1) {
        int M, T, P, R;
        cin >> M >> T >> P >> R;
        if( M == 0 && T == 0 && P == 0 && R == 0 ) break; 
 
        //■■■■チームテーブル作成■■■■
        vector<team> teams;
        team newteam;
        for(int i = 0; i <= P; i++)
            newteam.p.push_back(0);
 
        for(int i = 0; i < T; i++) {
            newteam.tID = i + 1;
            newteam.ansnum = 0;
			newteam.time = 0;
            teams.push_back( newteam );
        }
 
        //■■■■レコード取得■■■■
        for(int i = 0; i < R; i++) {
            int tID, pID, time_i, j;
            cin >> time_i >> tID >> pID >> j;
           
			if( j == 0 ) {
				teams.at(tID - 1).ansnum ++;
				teams.at(tID - 1).time += time_i + 20 * teams.at(tID - 1).p.at(pID);
			} else {
				teams.at( tID - 1 ).p.at( pID ) ++;
			}

        }

        sort( teams.begin(), teams.end() );
		
		cout << teams.at(teams.size() - 1).tID;
		for(int i = teams.size() - 2; i >= 0 ; i--) {
			if( teams.at(i) == teams.at(i + 1) ) {
				cout << "=" << teams.at(i).tID;
			} else {
				cout << "," << teams.at(i).tID;
			}
		}
		cout << endl;
 
    }
 
   // while(1){}
 
    return 0;
}

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

const int N = 500009;
const int mod = 1000000007;

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);
#define int long long int
#define endl "\n"
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()

int a,b;

void pre()
{
}

int32_t main()
{
	IOS;
	pre();
	cin>>a>>b;
	cout<<(6-a-b)<<endl;
}

Measured memory_bytes: 256
n, m = map(int, raw_input().split())
E = [[0]*n for i in xrange(n)]

for i in xrange(m):
    a, b = map(int, raw_input().split())
    E[a-1][b-1] = E[b-1][a-1] = 1

memo = {}
def dfs(state, v):
    if state == 0:
        return v == 0
    if (state, v) in memo:
        return memo[state, v]
    res = 0
    for i in xrange(n):
        if E[v][i] and (state >> i) & 1 == 1:
            res += dfs(state ^ (1 << i), i)
    memo[state, v] = res
    return res

print sum(dfs((2**n-1) ^ (1 << i), i) for i in xrange(n))


Measured memory_bytes: 2696
#include<iostream>

using namespace std;

int main(){
    int n;

    cin >> n;

    int k=n-n/10*10;
    if(k==2||k==4||k==5||k==7||k==9)cout << "hon" << endl;
    else if(k==3)cout << "bon" << endl;
    else cout << "pon" << endl;

    return 0;
}

Measured memory_bytes: 3040
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int max (int x, int y)
{
    if (x>=y) return x;
    else return y;
}

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    int ans = max(a*10+b+c, max(a+b*10+c, a+b+c*10));
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
//     for(int i=0; i<N;i++){
//     }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{

     str S,T;
     cin>>S>>T;

     if(S.size()<T.size()) {
       cout<<"UNRESTORABLE"<<endl; return 0;
     }
     if(S.size()==T.size()){
       for(int i=0;i<S.size();i++){
         if((S[i]!='?') && (S[i]!=T[i])){
           cout<<"UNRESTORABLE"<<endl; return 0;
         }
       }
     }

     int cnt=0;
     for(int i=(S.size()-T.size());i>=0;i--){
       for(int j=0;j<T.size();j++){
         if((S[i+j] == '?') || (S[i+j]==T[j])){
           cnt++;
         }
       }
       if(cnt==T.size()){

         for(int k=i;k<(i+T.size());k++){
           S[k] = T[k-i];
         }

         for(int k=0;k<S.size();k++){
           if(S[k]=='?') S[k]='a';
         }
         cout<<S<<endl; return 0;
       }
       cnt=0;
     }
    cout<<"UNRESTORABLE"<<endl; return 0;
}


Measured memory_bytes: 256
def main():
    from bisect import bisect_left
    from bisect import bisect_right

    N = int(input())

    An = map(int, input().split())
    Bn = map(int, input().split())
    Cn = map(int, input().split())

    A = sorted(An)
    B = sorted(Bn)
    C = sorted(Cn)

    print(sum([bisect_left(A, Bi) * (N - bisect_right(C, Bi)) for Bi in B]))
    return


main()


Measured memory_bytes: 29708
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] l = new int[n];

    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }

    Arrays.sort(l);

    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
      for (int j = i + 1; j < n - 1; j++) {
        for (int k = j + 1; k < n; k++) {
          if (l[i] + l[j] > l[k]) {
            ans++;
          } else {
            break;
          }
        }
      }
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 25724
#include <stdio.h>

#define MAX 13

int main()
{
	int n = 0, i = 0, flag = 0, cnt = 0;
	int numline[MAX] = {};
	int tmpline[MAX] = {};
	int num[101] = {};

	while ( scanf( "%d", &n ) == 1 ) {
		if ( n == 0 ) { break; }
		for ( i = 0 ; i < n ; i++ ) {
			scanf( "%d", &numline[i] );
		}
		flag = 1;
		cnt = 0;
		while ( flag ) {
			// B=P8=J8;zNs$N=i4|2=$r9T$&
			for ( i = 0 ; i < 101 ; i++ ) {
				num[i] = 0;
			}

			// B=P8=J8;zNs$N%+%&%s%H
			for ( i = 0 ; i < n ; i++ ) {
				num[numline[i]]++;
			}

			// B=P8=IQEYJ8;zNs$N:n@.
			for ( i = 0 ; i < n ; i++ ) {
				tmpline[i] = num[numline[i]];
			}

			cnt++; flag = 0;
			// numlineB$HtmplineB$NF1$8?tCM?t$r%+%&%s%H
			// BJ8;zNsD9$H0lCW$9$k>l9g$O, BFs$D$,F1$8G[Ns$G$"$k$3$H$r<($9
			for ( i = 0 ; i < n ; i++ ) {
				if ( tmpline[i] == numline[i] ) {
					flag++;
				}
			}

			if ( flag == n ) {
				/*for ( i = 0 ; i < n ; i++ ) {
					printf( "%3d %3d\n", numline[i], tmpline[i] );
				}*/
				flag = 0;
			} else { 
				// B0c$&J8;zNs$N>l9g$O!"<!$NA`:n$KHw$($F?tNs$N%3%T!<$r9T$&
				for ( i = 0 ; i < n ; i++ ) {
					numline[i] = tmpline[i];
				} 
				flag = 1;
			}
		}

		printf( "%d\n", cnt-1 );
		for ( i = 0 ; i < n ; i++ ) {
			if ( i == n-1 ) { 
				printf( "%d\n", tmpline[i] );
			} else { 
				printf( "%d ", tmpline[i] );
			}
		}
	}
	return 0;
}



Measured memory_bytes: 2024
#include <stdio.h>

int main(void){
	int i, j, before, count;
	char c, r[12] = {"yuiophjklnm"}, l[16] = {"qwertasdfgzxcvb"};
	while(1){
		c = getchar();
		if(c != '#'){
			for(i = 0;i < 11;i++)
				if(c == r[i]) break;
			for(j = 0;j < 15;j++)
				if(c == l[j]) break;
			if(i == 11)
				before = 0;
			else if(j == 15)
				before = 1;
			count = 0;
			while((c = getchar()) != '\n'){
				for(i = 0;i < 11;i++)
					if(c == r[i]) break;
				for(j = 0;j < 15;j++)
					if(c == l[j]) break;
				if(i == 11 && before == 1){
					count++;
					before = 0;
				}else if(j == 15 && before == 0){
					count++;
					before = 1;
				}
			}
		}
		else
			break;
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 932
#include<iostream>
#include<map>
#include<string.h>
using namespace std;
typedef long long ll;
const int maxn = 200+10;
char str[maxn];
int main(){
    int k;
    scanf("%d%s",&k,str+1);
    int len = strlen(str+1);
    if(len<=k) { printf("%s",str+1); return 0; }
    for(int i = 1; i <= k; i++)
        printf("%c",str[i]);
    puts("...");
    return 0;
}



Measured memory_bytes: 3172
x, k, d=map(int, input().split())

if x<=0:
  x*=(-1)
shou=x//d
amb=x%d
if k<=shou:
  print(x-k*d)
  exit()
else:
  if (k-shou)%2==0:
    print(amb)
    exit()
  else:
    print(d-amb)
    exit()


Measured memory_bytes: 9156
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
     int n;cin>>n;
     LL a[n];
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
     }
     LL dp[n] = {1000000};
     dp[0] = 0;
     dp[1] = min(abs(a[0]-a[1]),abs(a[0]-a[2]));
     for(int i= 2;i<n;i++)
     {
         dp[i] = min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));         
     }
    //  for(int i = 0 ;i<n;i++ )
    //  {
    //      cout<<dp[i]<<" ";
    //  }
     //cout<<endl;
     cout<<dp[n-1];

}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt() * 100;
		int g = sc.nextInt() * 10;
		int b = sc.nextInt();
		int rgb = r + g + b;
		
		if (rgb % 4 == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 35532
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

int main() {
    long long m, n, ans = 1, tmp = 1;
    cin >> m >> n;
    for (int i = 0; i < n % 10000; i++){
        ans *= m;
        ans %= mod;
    }
    for (int j = 0; j < 10000; j++){
        tmp *= m;
        tmp %= mod;
    }
    for (int j = 0; j < n / 10000; j++){
        ans *= tmp;
        ans %= mod;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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;}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v(m);
  rep (i, m) {
    cin >> v[i];
  }
  if (n >= m) {
    P(0);
    return 0;
  }

  sort(v.begin(), v.end());
  ll ans = v[m - 1] - v[0];
  vector<int> diff;
  rep (i, m - 1) {
    diff.push_back(v[i + 1] - v[i]);
  }
  sort(diff.rbegin(), diff.rend());
  rep (i, n - 1) {
    ans -= diff[i];
  }
  P(ans);
  return 0;
}



Measured memory_bytes: 1276
s = [int(a) for a in input().split(" ")]
N = s[0]
D2 = s[1] ** 2

count = 0
for i in range(N):
    s = [int(a) for a in input().split(" ")]
    dis2 = s[0] ** 2 + s[1] ** 2
    if(dis2 <= D2):
        count += 1

print(count)


Measured memory_bytes: 9204
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cstdio>
#include <queue>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
#define umap unordered_map
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

const long long mod = 1e9 + 7;
const int MAXN = 1e5 + 1;
int n;
int check(int i, const vector<int> &v) {
  if (i >= v.size())
    return 1;
  int p = v[i];
  for (int k = i; k < v.size(); ++k) {
    if (p < v[k])
      return 1;
    else if (v[k] < p)
      return -1;
  }
  return 1;
}
void solve() {
  cin >> n;
  vector<int> a(n);
  vector<int> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    s[i] = 0;
  }
  if (n == 1) {
    cout << 1 << endl;
    return;
  }
  int cnt = 0;
  int mode = check(0, a);
  int k = 0;
  while (k + 1 < n) {
    int add = 0;
    if (mode == 1) {
      while (k + 1 < n && a[k] <= a[k + 1]) {
        k++;
        add = 1;
      }
    } else if (mode == -1) {
      while (k + 1 < n && a[k] >= a[k + 1]) {
        k++;
        add = 1;
      }
    }
    k++;
    if (k >= n)
      break;
    cnt += add;
    s[k] = add;
    mode = check(k, a);
  }
  for (int i = 0; i + 1 < n; ++i) {
    if (s[i] == 1 && s[i + 1] == 1) {
      cnt--;
      i++;
    }
  }
  cout << cnt + 1 << endl;
}

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



Measured memory_bytes: 1024
import numpy as np
# import copy


n,k = map(int,input().split())
s = [int(a) for a in input()]

ls = []
start = s[0]
prev = s[0]
cnt = 1
for i in range(1,n):
    if s[i] == prev:
        cnt += 1
    else:
        prev = s[i]
        ls.append(cnt)
        cnt = 1
ls.append(cnt)

ma = 0
if start == 1:
    if len(ls) <= 2*k + 1:
        ma = len(s)
    else:
        attack_points = len(ls) // 2
        ls = np.array(ls)
        for i in range(attack_points+1-k):
            try:
                su = np.sum(ls[2*i:2*k+1+2*i])
            except IndexError:
                su = np.sum(ls[2*i:2*k+2*i])
            
            if su > ma:
                ma = su
else:
    if len(ls) <= 2*k - 1:
        ma = len(s)
    else:
        attack_points = (len(ls)+1) // 2 
        ls = np.array(ls)
        for i in range(attack_points+1-k):
            if i == 0:
                try:
                    su = np.sum(ls[:2*k])
                except IndexError:
                    su = np.sum(ls[:2*k-1])
                if su > ma:
                    ma = su
            elif i == attack_points - k:
                try:
                    su = np.sum(ls[2*i-1:2*k+2*i])
                except IndexError:
                    su = np.sum(ls[2*i-1:2*k+2*i-1])
                if su > ma:
                    ma = su
            else:
                try:
                    su = np.sum(ls[2*i-1:2*k+2*i])
                except IndexError:
                    su = np.sum(ls[2*i-1:2*k-1+2*i])
                if su > ma:
                    ma = su
print(ma)
                
                                

Measured memory_bytes: 15188
def main():
    s = input()
    si, ei = 0, len(s) - 1
    while True:
        if s[si] == 'A':
            break
        si += 1
    while True:
        if s[ei] == 'Z':
            break
        ei -= 1
    print(ei - si + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t n; cin >> n;
	string s;
	while(n > 0) {
		n--;
		s += (char)('a' + (n % 26));
		n /= 26;
	}
	reverse(s.begin(), s.end());
	cout << s << '\n';
	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF 1000000000000000007

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

Int gcd(Int x, Int y){
	if(y == 0) return x;
	return gcd(y, x%y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x,y);
}

bool sosuu(Int x){
	bool b = 1;
	if(x == 1) b = 1;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0){b = 0; break;}
	}
	return b;
}

int x;

int main(){
	cin >> x;
	int i = 1;
	for(int c = 0; c < x; i++){
		c += i;
	}
	cout << i-1 << endl;
	
	return 0;
}

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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> p(n, k-q);
  rep(i,q) {
    int a;
    cin >> a;
    --a;
    p[a]++;
  }
  rep(i,n) {
    if (p[i] <= 0) puts("No");
    else puts("Yes");
  }
  return 0;
}

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

typedef struct {
  char M;
  int N;
} Card;

void swap(Card *a,Card *b){
  Card tmp;
  tmp=*a;
  *a=*b;
  *b=tmp;
}
void BubbleSort(Card *s,int n){
  int j,i;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(s[j].N<s[j-1].N) swap(&s[j],&s[j-1]);
    }
  }
}

void SelectionSort(Card *d,int n){
  int i,j,min;
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(d[j].N<d[min].N) min=j;
    }
    swap(&d[i],&d[min]);
  }
}

int Stable(Card *s,Card *d,int n){
  int i;
  for(i=0;i<n;i++){
    if(s[i].M!=d[i].M) return 0;
  }
  return 1;
}
	
	

int main(){
  int n,i;
  Card s[40],d[40];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&s[i].M,&s[i].N);
    d[i]=s[i];
  }
  BubbleSort(s,n);
  SelectionSort(d,n);
  for(i=0;i<n;i++){
    if(i) printf(" ");
    printf("%c%d",s[i].M,s[i].N);
  }
  printf("\nStable\n");
  for(i=0;i<n;i++){
    if(i) printf(" ");
    printf("%c%d",d[i].M,d[i].N);
  }
  if(Stable(s,d,n)) printf("\nStable\n");
  else printf("\nNot stable\n");
  return 0;
}
  


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<char> x(10);
  for(int i=0;i<10;i++){cin>>x.at(i);}
  x.at(3)='8';
  
  for(int i=0;i<10;i++){cout<<x.at(i);}
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int ans=0,c=0;
	for(int i=0;i<3;i++){
		if(s[i]=='R'){
			c++;
		}
		else{
			if(ans<c){
				ans=c;
				c=0;
			}
		}
	}
	if(ans<c){
				ans=c;
				c=0;
			}
	cout<<ans<<endl;
    return(0);
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

template<typename T, typename U> bool ckmin(T &a, U b){ return b < a ? a = b, true : false; }
template<typename T, typename U> bool ckmax(T &a, U b){ return b > a ? a = b, true : false; }

struct camel{
    ll l, r, k;
    bool operator<(camel &oth){
            return (abs(l - r) > abs(oth.l - oth.r));
    }
};

ll tt, n;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> tt;
    while(tt--){
        cin >> n;
        ll ans = 0; camel tmp;
        vector<camel> v1, v2;
        for(int i = 0; i < n; ++i){
            cin >> tmp.k >> tmp.l >> tmp.r;
            tmp.k--; 
            if(tmp.l - tmp.r > 0) v1.pb(tmp);
            else if(tmp.l - tmp.r < 0) v2.pb(tmp);
            else ans += tmp.l;
        }
        sort(v1.begin(), v1.end());
        sort(v2.begin(), v2.end());
        set<int, greater<int>> p1; set<int> p2;
        for(int i = 0; i < sz(v1); ++i) p1.insert(i);
        for(int i = n - 1, j = 0; j < sz(v2); ++j, --i) p2.insert(i);
        for(int i = 0; i < sz(v1); ++i){
            ll l = v1[i].l, r = v1[i].r, k = v1[i].k;
            auto it = p1.lower_bound(k);
            if(it != p1.end()){
                p1.erase(it);
                ans += l;
            }
            else ans += r;
        }
        for(int i = 0; i < sz(v2); ++i){
            ll l = v2[i].l, r = v2[i].r, k = v2[i].k;
            auto it = p2.upper_bound(k);
            if(it != p2.end()){
                p2.erase(it);
                ans += r;
            }
            else ans += l;
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 17140
n, a, b = map(int, input().split())
x = list(map(int, input().split()))
ans = 0
for i in range(n-1):
    if (x[i+1] - x[i]) * a >= b:
        ans += b
    else:
        ans += (x[i+1]-x[i]) * a
print(ans)

Measured memory_bytes: 19932
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Text.Printf
import Data.Array.Unboxed

main :: IO ()
main = solve 1

solve :: Int -> IO ()
solve n = do
  x <- getl toInt
  unless (x == 0) $ do
    printf "Case %d:\n" n
    let ar = array ((0,0),(x-1,x-1)) $ zigzag x 0 0 1 :: UArray (Int,Int) Int
    mapM_ putStrLn $ fmt x $ elems ar
    solve (n+1)
    
zigzag :: Int -> Int -> Int -> Int -> [((Int,Int),Int)]
zigzag n i j k
  | i == n-1 && j == n-1 = [((i,j),k)]
  | even (i+j) && j == n-1 = ((i,j),k) : zigzag n (i+1) j (k+1)
  | even (i+j) && i == 0 = ((i,j),k) : zigzag n i (j+1) (k+1)
  | even (i+j) = ((i,j),k) : zigzag n (i-1) (j+1) (k+1)
  | odd (i+j) && i == n-1 = ((i,j),k) : zigzag n i (j+1) (k+1)
  | odd (i+j) && j == 0 = ((i,j),k) : zigzag n (i+1) j (k+1)
  | odd (i+j) = ((i,j),k) : zigzag n (i+1) (j-1) (k+1)

fmt :: Int -> [Int] -> [String]
fmt n xs
  | null xs = []
  | otherwise = concatMap (printf "%3d") (take n xs) : fmt n (drop n xs)

toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4228
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 int N;
 cin >> N;
 vector<int> A(N, 0);
 rep(i, N) {
   cin >> A[i];
 }
 sort(A.begin(), A.end());
 ll ans = 0;
 multiset<pint> s;
 s.insert({A[N-1],A[N-1]});
 for(int i = N-2;i >= 0;i--) {
   auto v = *s.rbegin();
   s.erase(s.find(v));
   ans += v.F;
   s.insert({A[i], v.F});
   s.insert({A[i], v.S});
 }

 cout << ans << endl;

 return 0;
}


Measured memory_bytes: 13456