akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vi customers(n);
		rep(i, n)
			scanf("%d", &customers[i]);
		sort(customers.begin(), customers.end());
		
		int waiting = 0;
		unsigned int sum = 0;
		rep(i, n-1){
			waiting += customers[i];
			sum += waiting;
		}
		
		printf("%u\n", sum);
	}
	
	return 0;
}

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

int main() {

    string s;
    cin >> s;

    if(s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I'){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

using namespace std;

signed main() {
  IOS;
  int A[2],turn=0,other=1,K, i=0;
  cin >> A[0] >> A[1] >> K;
  while (K > 0) {
    if ((A[turn] & 1) == 1)
      A[turn]--;
    A[other] += A[turn]/2;
    A[turn] /= 2;

    turn ^= 1;
    other ^= 1;
    K--;
  }
  cout << A[0] << " " << A[1] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
	  Scanner scan = new Scanner(System.in);
	  int ac = 0;
	  int wa = 0;
	  int tle = 0;
	  int re = 0;
	  int num = scan.nextInt();
	   String test = "";
	  for(int i=0;i<num+1;i++) {
		  test = scan.nextLine();
		  if (test.equals("AC")) {
			  ac++; 
		  }
		  if (test.equals("WA")) {
			  wa++;
		  }
		  if (test.equals("TLE")) {
			  tle++;
		  }
		  if (test.equals("RE")) {
			  re++;
		  }
	  }
	  
	  System.out.println(
			  "AC x " + ac+
			  "\nWA x " + wa+
			  "\nTLE x "+ tle+
			  "\nRE x " + re);
  }
}

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

int main(){
  int x1[1],x2[1],x3[1],x4[1];  
  cin >> x1[0] >> x1[1] >> x2[0] >> x2[1];
  
  x3[0]=(x1[1]-x2[1])+x2[0];
  x3[1]=-1*(x1[0]-x2[0])+x2[1];
  
  x4[0]=-1*(x2[1]-x1[1])+x1[0];
  x4[1]=(x2[0]-x1[0])+x1[1];

cout << x3[0] << " "<< x3[1] << " "<< x4[0] << " "<< x4[1] << " "<< endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int cnt=0;
    string W;
    string T;
    cin >> W;
    transform (W.begin (), W.end (), W.begin (), ::toupper);
    while(1){
        cin >> T;
        if(T == "END_OF_TEXT")
            break;
        transform (T.begin (), T.end (), T.begin (), ::toupper);
        if (W==T)
            cnt++;    
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3196
#include <assert.h>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout << i << "\n"

// const ll MOD = 998244353;
const ll MOD = 1e9 + 7;

double f[102];

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  rep(i,0,n){
    ll a;
    std::cin>>a;
    f[i]=(double)((double)1/a);
  }

  double ans=0;

  rep(i,0,n){
    ans+=f[i];
  }

  std::cout<<std::setprecision(10)<<std::fixed<<(double)(1/ans);


  return 0;
}

Measured memory_bytes: 256
//Practice more and more
//learn for better
#define bn begin()
#define en end()
#define mx 5000010
#define pb push_back
#define PI (2.0*acos(0.0))
#define ALL(a) a.begin(),a.end()
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rep(a,b) for(int a=0;a<b;++a)
#define fastio ios::sync_with_stdio(false)
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int>  vi;
typedef vector<ll>   vll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
	ll a,b,n,i,t,tmp,sum=0,k;
	map<ll,ll> mp;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>a;
		mp[a]++;
		sum+=a;
	}
cin>>n;
while(n--)
{
	cin>>a>>b;
	k=mp[a];
	if(a<b)
	{
		sum=sum+b*k-a*k;
		cout<<sum<<endl;
		mp[b]=k+mp[b];
		mp[a]=0;
	}
	else if(a>b)
	{
		sum=sum-(a-b)*k;
		cout<<sum<<endl;
		mp[b]=k+mp[b];
		mp[a]=0;
	}
	else
	cout<<sum<<endl;
}

	return 0;
}

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

int main() {

	int N ,X;
	cin >> N >> X;
	int	m[1100];
	int ans = 0;
	int min = 999999;
	for (int i = 0; i < N; i++)
	{
		int test;
		cin >>	m[i];
		X -= m[i];
		ans++;
		min = std::min(min,m[i]);
	}

	if(X > 0) ans += X / min;

	cout << ans << endl;

}

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

int main() {
	int n;
	cin >> n;
	int F[50];
	F[0] = F[1] = 1;
	for (int i = 2; i <= n; i++)F[i] = F[i - 1] + F[i - 2];

	cout << F[n] << endl;

	return 0;
}


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

int main(){
    int n;
    int num[3];
    int i = 0;
    cin >> n;
    while(n){
        if(n%10 == 1) num[i] = 9;
        else num[i] = 1;
        i++;
        n = n/10;
    }
    cout << num[0] + num[1]*10 + num[2]*100 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll a, b, n;
  cin >> a >> b >> n;
  ll mn = min(n, b-1);
  cout << floor(a*mn/b) - a * floor(mn/b) << endl;
  return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> X_cnt(26,0);
    vector<int> Y_cnt(26,0);
    REP(i,N) X_cnt[S[i]-'a'] ++;

    int ans = 0;
    REP(i,N){
        X_cnt[S[i]-'a']--;
        Y_cnt[S[i]-'a']++;

        int cnt = 0;
        REP(j,26){
            if(X_cnt[j]>0 && Y_cnt[j]>0) cnt++;
        }
        ans = max(ans,cnt);

    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    string s; cin >> s;
    const string S = "CODEFESTIVAL2016";
    int ans = 0;
    REP(i, s.size()) {
        if (s[i] != S[i]) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static final long INF = 1L << 60;
    public static long[] dp = new long[100100];
    public static void main(String[] args) throws Exception {
        Arrays.fill(dp,INF);
       Scanner sc = new Scanner(System.in);
       int N = Integer.parseInt(sc.next());
       dp[0] = 0;
       for(int i=0;i<=N;i++){
           dp[i+1] = Math.min(dp[i+1],dp[i]+1);
           for(int j=6;i+j<=N;j*=6){
               dp[i+j] = Math.min(dp[i+j],dp[i]+1);
           }
           for(int j=9;i+j<=N;j*=9){
               dp[i+j] = Math.min(dp[i+j],dp[i]+1);
           }
       }
       System.out.println(dp[N]);
    }
}


Measured memory_bytes: 22612
k = int(input())
X,Y = map(int,input().split())
x = max(abs(X),abs(Y))
y = min(abs(X),abs(Y))
c = (k-(x+y)%k)%k
if k%2 == 0 and (x+y)%2 == 1:
  print(-1)
  exit()
  
a = []
m = ((x+y-1)//k+1)
if x+y < k:
  if (x+y)%2 == 1:
    a.append((x,x-k))
    a.append((x+(k+x-y)//2,(-k+x+y)//2))
  else:
    a.append(((x+y)//2,-k+(x+y)//2))
  
if c%2 == 1 and x+y >= k:
  m += 1
A = abs((k*m-x-y)//2)
for i in range(m-1):
  l = k*i+k
  if A >= l:
    a.append((0,-1))
  elif A < l <= x+A:
    a.append((l-A,-A))
  elif x+A < l:
    a.append((x,l-x-2*A))
    
a.append((x,y))
print(len(a))
for i,j in a:
  if abs(X) < abs(Y):
    i,j = j,i
  if X < 0:
    i *= -1
  if Y < 0:
    j *= -1
  print(i,j)

Measured memory_bytes: 26000
// ABC086C - Traveling
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func readLine() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	//var n int
	//fmt.Scan(&n)
	n, _ := strconv.Atoi(readLine())
	nowt, nowx, nowy := 0, 0, 0
	txy := make([]int, 3)
	flag := true

	for i := 0; i < n; i++ {
		inputLine := strings.Split(readLine(), " ")
		for j := 0; j < 3; j++ {
			txy[j], _ = strconv.Atoi(inputLine[j])
		}
		dt := txy[0] - nowt
		dx := int(math.Abs(float64(txy[1] - nowx)))
		dy := int(math.Abs(float64(txy[2] - nowy)))

		if dt < dx+dy || dt%2 != (dx+dy)%2 {
			flag = false
			break
		}
	}

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

int main(){

	string s;
	cin >> s;
	for(int i = 0; i < s.length() - 1; ++i){
		if(s[i] == s[i + 1]){
			cout << i + 1 << " " << i + 2;
			return 0;
		}
	}
	for(int i = 0; i < s.length() - 2; ++i){
		if(s[i] == s[i + 2]){
			cout << i + 1 << " " << i + 3;
			return 0;
		}	
	}
	cout << -1 << " " << -1;
	return 0;

}

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

int main(){
  int n,m,i;
  cin>>n>>m;
  vector<ll> h(n,0),a(m,0),b(m,0);
  rep(i,n) cin>>h[i];
  rep(i,m) cin>>a[i]>>b[i];
  vector<int> good(n,1);
  rep(i,m){
    if(h[a[i]-1]<h[b[i]-1])good[a[i]-1]=0;
    else if(h[a[i]-1]>h[b[i]-1])good[b[i]-1]=0;
    else {good[a[i]-1]=0;good[b[i]-1]=0;}
  }
  int ans=0;
  rep(i,n)ans+=good[i];
  cout<<ans;

  return 0;
}

Measured memory_bytes: 5896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		long n = sc.nextLong();
		long count1 = 0;
		
		
		if(str.matches("1*")) {
			System.out.println("1");
			return;
		}
		
		for(int i = 0; i<str.length();i++) {
			if(str.charAt(i) == '1') {
				count1 ++;
			}else {
				break;
			}
		}
		if(count1 >= n) {
			System.out.println("1");
			return;
		}
		
		for (int t = 0; t < n; t++) {

			if (str.charAt(t) != '1') {
				System.out.println(str.charAt(t));
				return;
			}
		}
	}

}


Measured memory_bytes: 23252
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 100000000;
const int MAX_N = 50;
using namespace std;
int main() {
	int a[3];
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	sort(a, a + 3);
	int K;
	cin >> K;
	cout << a[0] + a[1] + (int)pow(2, K)*a[2] << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

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

    set<int> se[2];
    REP(i, S.size()) {
        se[i % 2].emplace(S[i]);
    }

    if (se[0].count('L') || se[1].count('R')) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<vector<int>>;
using VVV = vector<vector<vector<int>>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VVVL = vector<vector<vector<ll>>>;
using pq = priority_queue<int>;
template<class T>
using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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 under = (1 << 31);
int upper = under - 1;
ll UNDER = (1LL << 63);
ll UPPER = UNDER - 1;
const int MOD = 1e9 + 7;
const long double pi = 3.141592653589793;
int main() {
	int n;
	cin >> n;
	output(n * 2 * pi, 20);
	return 0;
}

Measured memory_bytes: 3748
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll a,b,c;
    cin>>a>>b>>c;
    if (c-a-b<=0)
        cout<<"No";
    else
    {
        if (4*a*b<(c-a-b)*(c-a-b))
            cout<<"Yes";
        else
            cout<<"No";
    }



}

Measured memory_bytes: 256
s=gets.chomp
j=[false]*5
s.length.times do |i|
  if s[i]==?N
    j[0]=true
  elsif s[i]==?S
    j[1]=true
  elsif s[i]==?W
    j[2]=true
  else
    j[3]=true
  end
end
j[5]=true if j[0]&&!j[1]
j[5]=true if !j[0]&&j[1]
j[5]=true if j[2]&&!j[3]
j[5]=true if !j[2]&&j[3]
puts j[5] ? :No : :Yes

Measured memory_bytes: 1788
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,i,j,c=0;
	ll res;
	string s1,s2;
	int k=0;
	cin>>n;
	cin>>s1>>s2;
	i=0;
	j=0;
	while(i<n-1&&j<n-1)
	{
		if(s1[i]==s1[i+1]){
			if(i+2<n)
			{
				if(i+3<n&&s1[i+2]==s1[i+3]){
					i+=2;
					j+=2;
					k++;
				}
				else if(s1[i+2]==s2[j+2])
				{
					c++;
					i+=2;
					j+=2;
				}
			}
			else
				break;
		}
		else
		{
			if(i+1<n){
				 if(i+2<n&&s1[i+1]==s1[i+2])
				 {
				 	c++;
				 	i++;
				 	j++;
				 }
				 else if(s1[i+1]==s2[i+1]){
				 	i++;
				 	j++;
				 }
			}
			else
				break;
		}
	}
	res=3;
	rep(i,n-1-c-2*k)
	{
		res*=2;
		res%=mod;
	}	
	rep(j,k)
	{
		res*=3;
		res%=mod;
	}
	//cout<<c<<endl;
	//rep(i,)
	//{
		//res*=2;
		//res%=mod;
	 // /cout <<res<< endl;
	//}
	 cout <<res<< endl;
} 


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

int main(int argc, char** argv){
  int N, M;
  cin >> N >> M;
  
  int flag[M];
  for(int cnt0=0; cnt0<M; cnt0++) flag[cnt0]=0;

  int tmpK;
  for(int cnt0=0; cnt0<N; cnt0++){
    cin >> tmpK;
    int tmpval;
    for(int cnt1=0; cnt1<tmpK; cnt1++){
      cin >> tmpval;
      flag[tmpval-1]++;
    }
  }
  
  int ans = 0;  
  for(int cnt0=0; cnt0<M; cnt0++) if(flag[cnt0] == N) ans++;

  printf("%d", ans);
  return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
	char buf[1100],str[100],*p;
	int c=0,i,j,h;
	scanf("%[a-zA-Z0-9',.-?! ]",buf);
	for(i=0,c=0;;i++){
		sscanf(buf,"%[^.,- ]",str);
		h=strlen(str);
		if(h>=3 &&h<=6){
			if(c)printf(" ");
			printf("%s",str);
			c++;
		}
		if(strstr(buf," ")==NULL)break;
		else p=strstr(buf," ")+1;
		strcpy(buf,p);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <map>
#include <cstdio>
using namespace std;

int main() {
    char com[10], str[13];
    map<string, bool> T;
    int n;
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        scanf("%s%s", com, str);
        if ( 'i' == com[0] ) {
            T[string(str)] = true;
        } else {
            if ( T[string(str)] ) {
                cout << "yes\n";
            } else {
                cout << "no\n";
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 47456
#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 n,x;
	cin>>n>>x;
	int a[n];
	for(int i =0; i<n ; i++)
		cin>>a[i];

	ll ans = 0;
	for(int i = 0; i<n-1; i++)
		if(a[i]+a[i+1]>x)
		{
			int y = a[i]+a[i+1]-x;
			ans += y;
			if(a[i+1]>=y)
				a[i+1]-=y;
			else
				a[i+1]=0;
		}
	cout<<ans<<endl;		
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int mod = 1000000007;
	static long inf = (long) 1e16;
	static int[] l, r;
	static int n, c, t;
	static ArrayList<Integer>[] ad;
	static long[][][] memo;
	static boolean f;
	static boolean[] vis[];
	static int[][] mat, mat1;
	static int[] ans, a;
	static ArrayList<Integer> rr, bb, gg;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		long ans = 0;
		int n = sc.nextInt();
		int[] a = sc.nextArrInt(n);
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				for (int k = j + 1; k < n; k++) {
					if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i]&&a[i]!=a[j]&&a[j]!=a[k]&&a[k]!=a[i])
						ans++;
				}
			}
		}
		System.out.println(ans);
		out.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 26320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main() {
  int n;
  priority_queue<ll> a;
  ll t,ans=0;
  cin>>n;
  rep(i,n){
    cin>>t;
    a.push(t);
    a.push(t);
  }
  a.pop();
  rep(i,n-1){
    ans+=a.top();
    a.pop();
  }
  cout<<ans;
}

Measured memory_bytes: 7420
n, m = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i).sort
kyori = Array.new(m-1)
(m-1).times do |i|
	kyori[i] = arr[i + 1] - arr[i]
end

kyori = kyori.sort
sum = 0
(m - 1 - (n-1)).times do |i|
	sum += kyori[i]
end
puts sum
# p arr
# p kyori
# puts kyori.inject(:+)





Measured memory_bytes: 24032
N = int(input())
T, A = input().split()
T = int(T)
A = int(A)
H = [int(i) for i in input().split()]

n = 0
for i in range(N):
    if abs(A - (T - H[i] * 0.006)) < abs(A - (T - H[n] * 0.006)):
       n = i

print(n + 1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

signed main(){
    int n,k;
    cin>>n>>k;
    if(k==0){
        cout<<n*n<<endl;
        return 0;
    }
    
    int ans = 0;
    for(int b=k+1;b<=n;b++){
        ans += (b-k) * (n/b) + max<ll>(0,n+1-(n/b*b+k));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int n, k;
long long int T[100000];

int check(long long int p)
{
    int i = 0;
    for(int j = 0; j < k; j++){
        long long int s = 0;
        while(s + T[i] <= p){
            s += T[i];
            i++;
            if(i == n) return n;
        }
    }
    return i;
}

int solve()
{
    long long int left = 0;
    long long int right = 100000 * 10000;
    long long mid;
    while(right - left > 1){
        mid = (left + right) / 2;
        int v = check(mid);
        if(v >= n) right = mid;
        else left = mid;
    }
    return right;
}

int main()
{
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> T[i];
    }
    long long int ans = solve();
    cout << ans << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];
  
  ll cnt=0;
  rep(i,n){
    int j = n-i-1;
    ll r = (a[j] + cnt) % b[j];
    if(r==0) continue;
    cnt += b[j] - r;
  }
    
  cout << cnt;
  
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <climits>
#include<vector>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include<cmath>
#include <limits>
using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

#define REP(i, a,b) for(i=a;i<b;i++) 
#define REP1(i,b,a) for(i=b-1;i>=a;i--)
#define output(x) cout<<x<<endl;
#define pb(x) push_back(x);
const int MOD = 1000000007;
ll circle(ll H) {
	if (H > 1)
		return circle(H / 2) * 2+1;
	else
		return 1;
}

int main() {
	ll N,i,j,K,H,ans;
	cin >> H;
	cout << circle(H) << endl;
	return 0;
}



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

using namespace std;

void show(int arr[], int n) {
	for (int i = 0; i < n - 1; i++)
		cout << arr[i] << " ";
	cout << arr[n - 1] << endl;
}

int bubbleSort(int arr[], int n) {
	bool f = true;
	int temp;
	int resCnt = 0;
	while (f) {
		f = false;
		for (int i = n - 1; i >= 1; i--)
			if (arr[i] < arr[i - 1]) {
				temp = arr[i];
				arr[i] = arr[i - 1];
				arr[i - 1] = temp;
				f = true;
				resCnt++;
			}
	}
	return resCnt;
}

int main() {
	int arr[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> arr[i];

	int resCnt = bubbleSort(arr, n);
	show(arr, n);
	cout << resCnt << endl;

	return 0;
}

Measured memory_bytes: 1164
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <string>

using namespace std;

int gcd(int a, int b)
{
	int buffer = a;
	if (b > a)
	{
		a = b;
		b = buffer;
	}

	int remainder = a%b;
	while (remainder != 0)
	{
		a = b;
		b = remainder;
		remainder = a%b;
	}
	return b;
}

int func(int a, int b, int c)
{
	return gcd(gcd(a, b), c);
}

int main()
{
	string a = "";
	int k;
	cin >> k;
	int output = 0;
	for (int a = 1; a <= k; a++)
	{
		for (int b = 1; b <= k; b++)
		{
			for (int c = 1; c <= k; c++)
			{
				output += func(a, b, c);
			}
		}
	}
	
	cout << output << endl;
    return 0;
}



Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var r, c int
	fmt.Scan(&r)
	fmt.Scan(&c)

	// a := make([][]int, r)
	// for i := 0; i < r; i++ {
	// 	b := make([]int, c)
	// 	for j := 0; j < c; j++ {
	// 		fmt.Scan(&b[j])
	// 	}
	// 	a[i] = b
	// }
	// fmt.Println(a)
	sheet := makeSheet(r, c)
	calc(sheet, r, c)
}

func makeSheet(r, c int) [][]int {
	a := make([][]int, r)
	for i := 0; i < r; i++ {
		b := make([]int, c)
		for j := 0; j < c; j++ {
			fmt.Scan(&b[j])
		}
		a[i] = b
	}
	return a
}

func calc(s [][]int, r, c int) {
	cSum := make([]int, c)
	for i := 0; i < r; i++ {
		rSum := 0
		for j := 0; j < c; j++ {
			num := s[i][j]
			rSum += num
			fmt.Printf("%d ", num)

			cSum[j] += num
		}
		fmt.Println(rSum)
	}

	allSum := 0
	for _, v := range cSum {
		fmt.Printf("%d ", v)
		allSum += v
	}
	fmt.Println(allSum)
}



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

using namespace std;

int ds[10];

bool check3(int c = 4) {
  if (!c) return true;
  for (int d = 1; d <= 9; d++) {
    bool result = false;
    if (ds[d] >= 3) {
      ds[d] -= 3;
      result = check3(c-1);
      ds[d] += 3;
      if (result) return true;
    }
    if (d <= 7 && ds[d] && ds[d+1] && ds[d+2]) {
      ds[d]--; ds[d+1]--; ds[d+2]--;
      result = check3(c-1);
      ds[d]++; ds[d+1]++; ds[d+2]++;
      if (result) return true;
    }
  }
  return false;
}

bool check() {
  for (int d = 1; d <= 9; d++) {
    if (ds[d] >= 2) {
      bool result = false;
      ds[d] -= 2;
      result = check3();
      ds[d] += 2;
      if (result) return true;
    }
  }
  return false;
}

int main() {
  string s;
  while (getline(cin, s)) {
    bool rs[10];
    int maxd = 0;
    for (int d = 1; d <= 9; d++) {
      rs[d] = false;
      ds[d] = 0;
    }
    for (int i = 0; i < 13; i++)
      ds[s[i]-'0']++;
    for (int d = 1; d <= 9; d++) {
      if (ds[d] >= 4) continue;
      ds[d]++;
      if (check()) {
        rs[d] = true;
        maxd = d;
      }
      ds[d]--;
    }
    if (maxd) {
      for (int d = 1; d <= 9; d++)
        if (rs[d])
          if (d == maxd)
            cout << d << endl;
          else
            cout << d << " ";
    } else
      cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
inputs = gets.strip.split(' ')
inputs.map!{|i| i.to_i}
W = inputs[0]
H = inputs[1]
x = inputs[2]
y = inputs[3]
r = inputs[4]


width_in  = ((x + r) <= W) && ((x - r) >= 0)
height_in = ((y + r) <= H) && ((y - r) >= 0)

if width_in && height_in
	puts "Yes"
else
	puts "No"
end


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

int main(){
  int n, w, sum[11];
  while(cin >> n >> w, n){
    fill_n( sum, 11, 0);

    int big = 0;
    for(int i = 0; i < n; i++){
      int v;
      cin >> v;
      ++sum[v / w];
      big = max( big, v / w);
    }
    int high = *max_element( sum, sum + big + 1);
    double ret = 0;
    for(int i = big; i >= 0; i--){
      ret += (double)((big - i) * sum[i]) / (big * high);  
    }
    cout << ret + 0.01 << endl;
  }
}

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

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

    //good luck kittu!
    float a, b; cin>>a>>b;
    for(int cost = 0; cost<2000; cost++){
        if(int(cost*0.08)==a && int(cost*0.1)==b) return cout<<cost<<"\n", 0;
    }
    cout<<"-1\n";
    return 0;
}

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

struct edge {
  int a;
  int b;
  int weight;
};
int *ufp, *ufr;
struct edge *ed;

void qsort1(int, int);
int UF_find(int);
void UF_union(int, int);
int Kruskal(int, int);

int main(void)
{
  int i, j, v, e, s, t, w, cost;
  scanf("%d %d", &v, &e);
  ufp = (int*)malloc(sizeof(int) * v);
  ufr = (int*)malloc(sizeof(int) * v);
  ed = (struct edge*)malloc(sizeof(struct edge) * e);
  for (i = 0; i < v; i++) {
    ufp[i] = i;
    ufr[i] = 0;
  }
  for (i = 0; i < e; i++) {
    scanf("%d %d %d", &s, &t, &w);
    ed[i].weight = w;
    ed[i].a = s;
    ed[i].b = t;
  }
  cost = Kruskal(v, e);
  printf("%d\n", cost);
  free(ufp);
  free(ufr);
  free(ed);
}

void qsort1(int left, int right)
{
  int pivot = ed[(left + right) / 2].weight, i = left, j = right;
  if (i >= j) return;
  do {
    while (ed[i].weight < pivot) i++;
    while (ed[j].weight > pivot) j--;
    if (i <= j) {
      struct edge temp = ed[i];
      ed[i] = ed[j];
      ed[j] = temp;
      i++;
      j--;
    }
  } while (i <= j);
  qsort1(left, j);
  qsort1(i, right);
}

int UF_find(int a)
{
  if (ufp[a] == a) return a;
  else {
    ufp[a] = UF_find(ufp[a]);
    return ufp[a];
  }
}

void UF_union(int a, int b)
{
  if (ufr[a] < ufr[b]) ufp[a] = b;
  else {
    ufp[b] = a;
    if (ufr[a] == ufr[b]) ufr[a]++;
  }
}

int Kruskal(int size, int esize)
{
  int i, selected = 0, cost = 0;
  qsort1(0, esize - 1);
  for (i = 0; i < esize; i++) {
    int ea = UF_find(ed[i].a), eb = UF_find(ed[i].b);
    if (ea != eb) {
      UF_union(ea, eb);
      cost += ed[i].weight;
      selected++;
    }
    if (selected == size - 1) break;
  }
  return cost;
}


Measured memory_bytes: 2912
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=305;
int dis[maxn][maxn];
bool notneed[maxn][maxn];
int main(){
  int n;scanf("%d",&n);
  for(int i=1;i<=n;++i){
    for(int j=1;j<=n;++j){
      scanf("%d",&dis[i][j]);
    }
  }
  bool flag=true;
  for(int i=1;i<=n;++i){
    for(int j=1;j<=n;++j){
      for(int k=1;k<=n;++k){
	if(i!=j&&j!=k&&k!=i){
	  if(dis[i][j]+dis[j][k]<dis[i][k])flag=false;
	  if(dis[i][j]+dis[j][k]==dis[i][k])notneed[i][k]=true;
	}
      }
    }
  }
  if(!flag){
    printf("-1\n");
  }else{
    long long ans=0;
    for(int i=1;i<=n;++i){
      for(int j=i+1;j<=n;++j){
	if(!notneed[i][j])ans+=dis[i][j];
      }
    }
    printf("%lld\n",ans);
  }
  return 0;
}


Measured memory_bytes: 640
n=int(input())
li = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(li[n-1])

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

int main()
{
  ll n; cin >> n;
  ll m; cin >> m;
  cout << n*(n-1)/2 + m*(m-1)/2 << endl;

  return 0;
}


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

int main() {
    int N;
    int64_t T;
    cin >> N >> T;
    vector<int64_t> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

    map<int64_t, int> diff;
    int64_t min_key = A.at(0);
    // for (int i = 0; i < N; i++) {
    //     for (int j = i + 1; j < N; j++) {
    //         // max_key = max(max_key, A.at(j) - A.at(i));
    //         // cout << A.at(j) - A.at(i) << endl;
    //         if (diff.count(A.at(j) - A.at(i))) {
    //             diff[A.at(j) - A.at(i)] += 1;
    //         }
    //         else {
    //             diff[A.at(j) - A.at(i)] = 1;
    //         }
    //     }
    // }
    for (int i = 1; i < N; i++) {
        min_key = min(min_key, A.at(i));
        if (diff.count(A.at(i) - min_key)) {
            diff[A.at(i) - min_key] += 1;
        }
        else {
            diff[A.at(i) - min_key] = 1;
        }
    }
    cout << diff.rbegin()->second << endl;
    // cout << diff[10] << endl;

    return 0;
}


Measured memory_bytes: 7296
N,K=map(int,input().split())
V=list(map(int,input().split()))
ans=0
for i in range(N):
    for j in range(i,N+1):
        if i+N-j<=K:
            k=K-(i+N-j)
            s=V[:i]+V[j:]
            s.sort()
            c=0
            for t in s:
                if k>=1 and t<0:
                    k-=1
                else:
                    c+=t
            ans=max(c,ans)
print(ans)


Measured memory_bytes: 40816
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    int N, M;
    cin >> N >> M;
    
    string num = "";
    for (int i = 0; i < N; i++) num += "?";
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        if (num[s-1] != '?' && num[s-1] - '0' != c) {
            cout << "-1" << endl;
            return 0;
        }
        num[s-1] = c + '0';
    }
    
    if (N == 1 && (num[0] == '0' || num[0] == '?')) {
        cout << 0 << endl;
        return 0;
    }
    
    for (int i = (int)pow(10, N-1); i < (int)pow(10, N); i++) {
        string t = to_string(i);
        bool flag = true;
        for (int j = 0; j < N; j++) {
            if (t[j] == num[j] || num[j] == '?') {
            } else {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    
    return 0;
}


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

using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  
  int a_len = a.length(), b_len = b.length();

  string res = "";
  
  if (a_len > b_len) res += "GREATER";
  if (a_len < b_len) res += "LESS";
  if (a_len == b_len) {
    for (int i=0; i<a_len; i++) {
      if (a[i] > b[i]) {
          cout << "GREATER" << endl;
          return 0;
      }
      if (a[i] < b[i]) {
        cout << "LESS" << endl;
        return 0;
      }
    }
	  res += "EQUAL";
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = sc.nextInt();
        int C = sc.nextInt();
        int[] s = new int[N];
        int[] t = new int[N];
        int[] c = new int[N];
        for (int i = 0; i < N; ++i) {
            s[i] = sc.nextInt();
            t[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        System.out.println(solve(s, t, c, C));

        sc.close();
    }

    static int solve(int[] s, int[] t, int[] c, int C) {
        int[] sortedIndices = IntStream.range(0, s.length).boxed().sorted((i1, i2) -> Integer.compare(s[i1], s[i2]))
                .mapToInt(x -> x).toArray();

        List<Recorder> recorders = new ArrayList<>();
        for (int index : sortedIndices) {
            Recorder recorder = new Recorder(c[index], t[index]);

            int recorderIndex = findRecorder(s[index], c[index], recorders);
            if (recorderIndex == -1) {
                recorders.add(recorder);
            } else {
                recorders.set(recorderIndex, recorder);
            }
        }

        return recorders.size();
    }

    static int findRecorder(int startTime, int channel, List<Recorder> recorders) {
        int result = -1;
        for (int i = 0; i < recorders.size(); ++i) {
            if (recorders.get(i).channel == channel) {
                return i;
            }

            if (startTime > recorders.get(i).endTime) {
                result = i;
            }
        }

        return result;
    }
}

class Recorder {
    int channel;
    int endTime;

    Recorder(int channel, int endTime) {
        this.channel = channel;
        this.endTime = endTime;
    }
}

Measured memory_bytes: 96484
#include<stdio.h>
int main()
{
    int a,b,i;
    scanf("%d%d",&a,&b);
    if(a>b)
    {
        for(i=0;i<a;i++)
        {
            printf("%d",b);
        }
    }
    else
    {
        for(i=0;i<b;i++)
        {
            printf("%d",a);
        }
    }
    return 0;
}


Measured memory_bytes: 1732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		proconScan proScan = new proconScan(" ");
		proScan.scan();
		Long xInteger = proScan.nextLong();
		Long buf = new Long(0);
		Long ans = new Long(1);
		while (true) {
			buf+=ans;
			if (xInteger <= buf) {
				break;
			}
			ans++;
		}
		System.out.println(ans);
		proScan.proconEnd();
	}

}

class proconScan {
	private BufferedReader br;
	private String inLine;
	private String[] inString;
	private Integer idx;
	private String splitChar;

	public proconScan() {
		br = new BufferedReader(new InputStreamReader(System.in));
		idx = 0;
		splitChar = " ";
	}

	public proconScan(String split) {
		br = new BufferedReader(new InputStreamReader(System.in));
		idx = 0;
		splitChar = split;
	}

	public void proconEnd() throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		br.close();
	}

	public String scan() throws IOException {
		idx = 0;
		inLine = br.readLine();
		inString = inLine.split(splitChar, 0);
		return inLine;
	}

	public Integer scanInteger1() throws IOException {
		scan();
		return Integer.parseInt(inString[0]);
	}

	public String backLine() {
		return inLine;
	}

	public String nextString() {
		return inString[idx++];
	}

	public String[] getString() {
		return inString;
	}

	public Long nextLong() {
		Long num;
		try {
			num = Long.parseLong(inString[idx++]);
		} catch (NumberFormatException e) {
			num = null;// TODO: handle exception
		}
		return num;
	}

	public Integer nextInteger() {
		Integer num;
		try {
			num = Integer.parseInt(inString[idx++]);
		} catch (NumberFormatException e) {
			num = null;// TODO: handle exception
		}
		return num;
	}

	public Integer[] getInteger() {
		Integer[] num = new Integer[this.getLen()];

		for (int i = 0; i < this.getLen(); i++) {
			num[i] = Integer.parseInt(inString[i]);
		}

		return num;
	}

	public Float nextFloat() {
		Float num;
		try {
			num = Float.parseFloat(inString[idx++]);
		} catch (NumberFormatException e) {
			num = null;// TODO: handle exception
		}
		return num;
	}

	public Float[] getFloat() {
		Float[] num = new Float[this.getLen()];

		for (int i = 0; i < this.getLen(); i++) {
			num[i] = Float.parseFloat(inString[i]);
		}

		return num;
	}

	public Integer getLen() {
		return inString.length;
	}

	public int[] getInt() {
		int[] num = new int[this.getLen()];

		for (int i = 0; i < this.getLen(); i++) {
			num[i] = Integer.parseInt(inString[i]);
		}

		return num;
	}

}

Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <queue>

#define rep(i,n) for (int i=0; i < (n); ++i)
using ll = long long ;
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;

int happy[110000][3] ;
int dp[110000][3] ;

//0 : umi
//1 : yama
//2 : ie

int main() {

    int n,k ;
    cin >> n  ;
    for(int i=1;i<=n;i++){
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2] ;
    }    

    for(int i=1;i<=n;i++){
        for(int place=0;place<3;place++){
            for(int placeY = 0 ;placeY<3;placeY++){
                if(placeY==place) continue ;
                dp[i][place] = max(dp[i][place], dp[i-1][placeY] + happy[i][place]) ;
            }
        }
    }

    int ans = 0 ;
    for(int i=0;i<3;i++){
        ans = max(ans,dp[n][i]) ;
    }

    cout << ans << endl ;

    return 0 ;
}

Measured memory_bytes: 5904
//問題URL
//

//解き方メモ
//
    
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
  int n;
  int maxIdx,minIdx;
  int max,min;

  cin >> n;

  vector<int> v;

  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }

  maxIdx = distance( v.begin(), max_element(v.begin(),v.end()) );
  minIdx = distance( v.begin(), min_element(v.begin(),v.end()) );

  max = v[maxIdx];
  min = v[minIdx];

  if (abs(max) >= abs(min)) {
    
    cout << 2*n-1 << endl;

    for (int i = 1; i <= n; i++) {
      cout << maxIdx+1 << " " << i << endl;
    }
    for (int i = 1; i < n; i++) {
      cout << i << " " << i+1 << endl;
    }
    
  } else if(abs(max) < abs(min)) {
    
    cout << 2*n-1 << endl;

    for (int i = 1; i <= n; i++) {
      cout << minIdx+1 << " " << i << endl;
    }
    for (int i = n; i > 1; i--) {
      cout << i << " " << i-1 << endl;
    }
    
  }
  
  return 0;
}


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

int main(){
    int n;
    while(cin >> n, n){
        vector<int> A(n);
        for(auto &v: A)
            cin >> v;
        
        int sum = 0;
        for(auto v: A)
            sum += v;
        
        int count = 0;
        for(auto v: A)
            count += v*n <= sum;
        
        cout << count << endl;
    }
    
    return 0;
}



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

#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define ll long long 
#define hii cout << "hii" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define int ll
#define mpp make_pair
#define endl '\n'
#define ff first 
#define ss second
#define all(s) s.begin(), s.end()
#define fuck_you_scanf ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define si size()

const int N = 2e3 + 5;
const int MAX = 1e2 + 5;

int arr[N];
int brr[N];
const int mod = 1e9 + 7;
int DP[N][N];

int f(int i, int j, int n, int m)
{
    if(i == n or j == m) return 1;
    if(DP[i][j] != -1) return DP[i][j];
    if(arr[i] == brr[j])
    {
        return DP[i][j] = (f(i + 1, j, n, m) + f(i, j + 1, n, m)) % mod;
    }
    
    int ans1 = f(i + 1, j, n, m);
    int ans2 = f(i, j + 1, n, m);
    
    int ret = ans1 + ans2;
    ret %= mod;
    ret = ret - f(i + 1, j + 1, n, m);
    ret += mod;
    ret %= mod;
    return DP[i][j] = ret;
}

int32_t main()
{
    int n, m;
    cin >> n >> m;
    memset(DP, -1, sizeof(DP));
    
    FOR(i, 0, n) cin >> arr[i];
    FOR(i, 0, m) cin >> brr[i];
    cout << f(0, 0, n, m);
}

Measured memory_bytes: 32000
#include<bits/stdc++.h>
using namespace std;
string divide[4]={"dream", "dreamer", "erase", "eraser"};
int main(){
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());
    bool can = true;
    for (int i = 0; i < s.size(); ){
        bool can2 = false;
        for (int j = 0; j < 4; j++){
            string d = divide[j];
            if(s.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            } 
        }
        if (!can2){
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 512