akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std ;

int r , c ;
int d[10][10000] = {} ;
int b[11] = { 1,2,4,8,16,32,64,128,256,512,1024 } ;


int main(){
	
	while(1){
		cin >> r >> c ;
		if( r==0 && c==0 ) break ;
		
		for( int i=0 ; i<r ; i++ ){
			for( int j=0 ;  j<c ; j++ ){
				cin >> d[i][j] ;
			}
		}
		
		int ans = 0 ;
		
		for( int i=0 ; i<b[r] ; i++ ){
			int D[10000] = {0} ;
			
			for( int j=0 ; j<r ; j++ ){
				for( int k=0 ; k<c ; k++ ){
					if( (i & b[j]) == 0 && d[j][k] == 0 ||
						( (i & b[j])  && d[j][k] ) ) D[k]++;
				}
			}
			
			int tmp = 0 ;
			
			for( int j=0 ; j<c ; j++ ){
				tmp += max( D[j] , r-D[j] ) ;
			}
			
			ans = max( ans ,tmp ) ;
		}
		
		cout << ans << endl ;
	
	}
	
return 0 ; 
}

Measured memory_bytes: 1592
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<string.h>
#include<set>
#include<stdlib.h>
#include<sstream>
#include<stack>
#include<time.h>
using namespace std;
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef pair<LL, LL> P;
inline LL in() {
	LL temp;
	cin >> temp;
	return temp;
}
int main() {
	int n, cnt = 0, ans = 0;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n - i; j++) {
			if (s[i + j] != t[j]) {
				break;
			}
			if (j == n - i - 1) {
				cnt = j + 1;
			}
		}
		ans = max(cnt, ans);
	}
	cout << 2 * n - ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <climits>
#include <iomanip>

using namespace std;

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

	int n;
	cin >> n;
	int ans = 0;
	int now = 0;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		if (i == 0)continue;
		if (h[i - 1] >= h[i]) {
			now++;
		}
		else {
			ans = max(ans, now);
			now = 0;
		}
	}
	ans = max(ans, now);

	cout << ans << endl;

	return 0;
}

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

using namespace std;

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define rep(i, n) for(int i = 0; i < n; i++)
#define outl(x) cout<< (x) << '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

template<typename Tn> Tn gcd(Tn a, Tn b)
{
    return (b ? gcd(b, a % b) : a);
}

template<typename Tn> Tn lcm(Tn a, Tn b)
{
    return a / gcd(a, b) * b;
}

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

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

int main()
{
    int n, k;
    string s;

    ci >> n >> s >> k;

    char c = s[k - 1];
    
    for(int i = 0; i < n; i++) if(s[i] != c) s[i] = '*';

    co << s << en;
    
    return 0;
}


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

int main(){
    string s; cin>>s;
    int n=s.length();
    
    string ans="No"; bool flag=false;
    for(int i=0;i<n;i++){
        if(!flag){
            if(s[i]=='C') flag=true;
        }
        else{
            if(s[i]=='F') ans="Yes";
        }
    }

    cout<<ans<<endl;
    return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

bool check(int k, const vector<int>& h, int A, int B) {
  int N = h.size();
  vector<ll> rsd(N);
  REP(i,N) rsd[i] = h[i] - (ll)k * B;
  ll cnt = 0;
  REP(i,N) if(rsd[i] > 0) cnt += (rsd[i] + A - B - 1) / (ll)(A - B);
  return (k >= cnt);
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  vector<int> h(N);
  REP(i,N) cin >> h[i];

  int lb = 0, ub = 1e9;
  while((ub - lb) > 1) {
    int mid = (lb + ub) / 2;
    if(check(mid, h, A, B)) ub = mid;
    else lb = mid;
  }
  cout << ub << endl;
  return 0;
}



Measured memory_bytes: 1408
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;
using System.Numerics;

public class Program
{
    public void Solve()
    {
        var match = Regex.IsMatch(Reader.String(), "C.*F");
        Console.WriteLine(match ? "Yes" : "No");
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 5580
// AtCoder - Regular Contest 103 - C /\/\/\/
#include <bits/stdc++.h>
using namespace std;

const int N = 100 * 1000 + 10;
int n;
map<int, int> cnt1, cnt2;

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

    cin >> n;

    for (int i = 0, x; i < n; i++) {
        cin >> x;
        if (i % 2)
            cnt1[x]++;
        else
            cnt2[x]++;
    }

    int most1 = 0, app1 = 0, most2 = 0, app2 = 0;
    int app12 = 0, app22 = 0;

    for (int i = 1; i < N; i++) {
        if (app1 < cnt1[i]) {
            app12 = app1;
            most1 = i;
            app1 = cnt1[i];
        } else if (app12 < cnt1[i]) {
            app12 = cnt1[i];
        }

        if (app2 < cnt2[i]) {
            app22 = app2;
            most2 = i;
            app2 = cnt2[i];
        } else if (app22 < cnt2[i]) {
            app22 = cnt2[i];
        }
    }

    int ans = 0;
    if (most1 == most2) {
        ans = min( (n/2 - app1) + (n/2 - app22),
                (n/2 - app12) + (n/2 - app2));
    } else {
        ans = (n/2 - app1) + (n/2 - app2);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>

using namespace std;

int main() {
    int a, b,c,aux;
    cin >> a >> b >>c;
     if (a == b && a== 5 && c==7) cout<<"YES";
     else
     if (a == c && a== 5 && b==7) cout<<"YES";
     else
     if (c == b && c== 5 && a==7) cout<<"YES";
     else cout<<"NO";
    return 0;
}

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

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

int main(void) {
    int n;
    scanf("%d",&n);
    long long ret=0;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) {
            int val=gcd(i,j);
            for(int k=1;k<=n;k++) {
                ret+=gcd(val,k);
            }
        }
    }
    printf("%lld",ret);
}

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

int main (){

    int N;
    int K;
    cin >> N >> K;
    int ans=0;
    vector<int> list(N);
    for(int i = 0;i < N;i++){
        cin >> list.at(i);
    }
    sort(list.begin(),list.end());

    for(int i = 0;i < K;i++){
        ans += list.at(i);
    }
    

    cout << ans << endl;
}

Measured memory_bytes: 3628
/***
 **   A S M Atikur Rahman
 **   Update: 17-12-2019
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<time.h>
#include<limits.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<utility>
#include<iterator>
#include<algorithm>
#include<cassert>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(a,n) for(int i=(a); i<(n); i++)
#define rFor(n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)
#define Mset(ara, val) memset(ara, val, sizeof(ara))

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}




int main( int argc, char *argv[] )
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stout);
    string s;
    cin>>s;
    int l,i,j,fg=0;
    l=s.length();
    for(i=0;i<l/2; i++)
    {
        if(s[i]!=s[l-1-i]) fg=1;
    }
    l=l/2;
    for(i=0;i<l/2; i++)
    {
        if(s[i]!=s[l-1-i]) fg=1;
    }
    l=s.length();
    for(i=(l+3)/2; i<l;i++)
    {
        if(s[i]!=s[l-1-i]) fg=1;
    }
    if(fg) printf("No\n");
    else printf("Yes\n");





    return 0;
}
























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

int main(){
	int n;
	string s, t;
	cin >> n >> s >> t;
	for(int i = max(0, int(s.size()) - int(t.size())); i < s.size(); i++) if(s[i] == t[0]){
		bool f = true;
		for(int j = i + 1; j < s.size() && j - i < t.size(); j++) f &= s[j] == t[j - i];
		if(f){
			cout << max(n, i + int(t.size())) << endl;
			return 0;
		}
	}
	cout << max(n, int(s.size()) + int(t.size())) << endl;
}

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

int main(){
    int n,m;
    vector <pair<int,int> > v;
    vector <int> v1;
    cin>>n>>m;
    for (int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        v.push_back(make_pair(a,b));
    }
    for (int i=0;i<=pow(10,n);i++){
        int count1=0;
        string str=to_string(i);
        if (m>0){
        for (int j=0;j<v.size();j++){
            char c='0'+v[j].second;
            if (str[v[j].first-1]==c)
                ++count1;
        }
        //cout<<i<<' '<<count1<<endl;
        if (count1==v.size() and str.length()==n){
            cout<<str<<endl;
            return 0;
        }
        }
        else {
            if (str.length()==n){
                cout<<str<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	ll n, m;
	cin >> n >> m;
	if(n-m>1 || m-n>1) cout << '0' << endl;
	else
	{
		ll ans;
		if(n>m) swap(n, m);
		if(n==m)
		{
			ans=2;
			for(ll i=1; i<=n; i++) ans=(ans*((i*i)%MOD))%MOD;
		}
		else
		{
			ans=m;
			for(ll i=1; i<=n; i++) ans=(ans*((i*i)%MOD))%MOD;
		}
		cout << ans << endl;
	}
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

int n,m;
int a[1001][1001];
ll mod=1000000007;
ll ans=0;
ll dp[1001][1001]={{0}};


int main()
{
    IOS;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char s;
            cin>>s;
            if(s=='.')
                a[i][j]=0;
            else
                a[i][j]=1;
        }
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i][j]==1)
                continue;
            if(i>=1)
            dp[i][j]=(dp[i-1][j]+dp[i][j])%mod;
            if(j>=1)
            dp[i][j]=(dp[i][j-1]+dp[i][j])%mod;
        }
    }
    cout<<dp[n-1][m-1];
}


Measured memory_bytes: 12032
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val d = Array(N + 1) { 0 }

    for (i in 1 .. N) {
        var m = i
        for (j in 2 .. i) {
            while(m % j == 0) {
                m /= j
                d[j]++
            }
        }
    }

    var res = 0

    for (i in 1..N) for (j in 1 .. N) for (k in j + 1 .. N) {
        if (i == j || i == k)
            continue
        if (d[i] < 2 || d[j] < 4 || d[k] < 4)
            continue
        res++
    }

    for (i in 1..N) for (j in 1..N) {
        if (i == j) continue
        if (d[i] < 2 || d[j] < 24)
            continue
        res++
    }

    for (i in 1..N) for (j in 1..N) {
        if (i == j) continue
        if (d[i] < 4 || d[j] < 14)
            continue
        res++
    }

    for (i in 1..N) if (d[i] >= 74) res++

    println(res)
}


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

#define pb emplace_back
#define fi first
#define se second
#define m_p make_pair
#define vi vector<int>
#define pi pair<int, int>
#define mem(a,b) memset(a,b,sizeof(a))
#define el cout<<endl
#define sz(a) (int)a.size()
const int mod = (int)1e9+7;
typedef long long int ll;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = (int)1e5+5;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int x;
	cin>>x;
	cout<< ((x>=30) ? "Yes\n":"No\n");	
}

ll power(ll a,ll b, ll md=mod){
	ll r=1;
	while(b){
		if(b%2) 
			r=(r*a)%md;
		a=(a*a)%md;
		b>>=1;
	}
	return r;
}

Measured memory_bytes: 3600
S = 'L' + gets.chomp + 'R'
N = S.length - 2
ml = Array.new(N + 1, 1)

r = false
1.upto(N) do |i|
	if S[i] == 'R' && S[i + 1] == 'R'
		ml[i + 2] += ml[i]
		ml[i] = 0
	end
end

N.downto(1) do |i|
	if S[i] == 'L' && S[i - 1] == 'L'
		ml[i - 2] += ml[i]
		ml[i] = 0
	end
end

puts ml[1..N].join(' ')

Measured memory_bytes: 3324
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


h, w = LI()
n = I()
L = LI()


ans = [[0] * w for _ in range(h)]


k = 0
cnt = 0
for y in range(h):
    if not y % 2:
        for x in range(w):
            ans[y][x] = k + 1
            cnt += 1
            if cnt >= L[k]:
                k += 1
                cnt = 0
    else:
        for x in range(w-1, -1, -1):
            ans[y][x] = k + 1
            cnt += 1
            if cnt >= L[k]:
                k += 1
                cnt = 0


for i in range(h):
    print(*ans[i])

Measured memory_bytes: 42608
#include<stdio.h>
unsigned shift(unsigned b, int x)
{
	return x>=0 ? (b>>x) : (b<<-x);
}
#define P(x,y) (fp[y]&shift(fb,x))
int main()
{
	char line[10];
	unsigned map[8+3], t, fb, *fp;
	int i, j, find;
	while (1) {
		map[8]=map[9]=map[10]=0;
		find = 0;
		for (i = 0; i < 8; i ++) {
			if (!fgets (line, 10, stdin))
				return 0;
			t = 0;
			for (j = 0; j < 8; j ++) {
				t = t * 2 + line[j] - '0';
				if (!find) {
					if (line[j] == '1') {
						fb = 0x80U >> j;
						fp = map+i;
						find = 1;
					}
				}
			}
			map[i] = t;
		}
		fgets (line, 10, stdin);
		if (P(0,1) && P(1,0) && P(1,1))
			puts("A");
		else if (P(0,1) && P(0,2) && P(0,3))
			puts("B");
		else if (P(1,0) && P(2,0) && P(3,0))
			puts("C");
		else if (P(0,1) && P(-1,1) && P(-1,2))
			puts("D");
		else if (P(1,0) && P(1,1) && P(2,1))
			puts("E");
		else if (P(0,1) && P(1,1) && P(1,2))
			puts("F");
		else
			puts("G");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define caseout(i, x) cout << "Case #" << i << ": " << x << endl;


int n,q;
string s;
vector<pair<char,char>>x(200010);


bool okl(int m){
  rep(i,q){
    if(x[i].first==s[m]){
      if(x[i].second=='L')m--;
      else m++;
    }
    if(m==-1)return true;
    if(m==n)return false;
  }
  return false;
}

bool okr(int m){
  rep(i,q){
    if(x[i].first==s[m]){
      if(x[i].second=='L')m--;
      else m++;
    }
    if(m==n)return true;
    if(m==-1)return false;
  }
  return false;
}


int bsr(){
  int l=-1,r=n;
  
  while(r-l>1){
    int m=(l+r)/2;
    if(okr(m))r=m;
    else l=m;
  }
  return r;
}
    

int bsl(){
  int l=-1,r=n;
  
  while(r-l>1){
    int m=(l+r)/2;
    if(okl(m))l=m;
    else r=m;
  }
  return l;
}



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>q;
    cin>>s;
    
    
    rep(i,q){
      cin>>x[i].first>>x[i].second;
    }
    
    
    cout<<bsr()-1-bsl()<<endl;
    return 0;
}

Measured memory_bytes: 1104
N=int(input())
ans = 0
for i in range(1,N+1,2):
  nn = i
  c = 0
  s = 1
  d = []
  while s*s <= i:
    if nn%s == 0:
      d.append(s)
      c += 1
      if nn != s:
        d.append(nn//s)
        c += 1
    s += 1
  if c == 8:
    ans += 1
#    print(i,d)
print(ans)


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)

def main():
    n,k = [int(i) for i in input().strip().split()]
    A = [int(i) for i in input().strip().split()] 

    for i in range(k, n):
        if A[i] > A[i - k]:
            print("Yes")
        
        else:
            print("No")
    return

if __name__ == "__main__":
    main()


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

int main ()
{

    char N[4];
    cin>>N;
    if(N[0]=='7' || N[1]=='7' || N[2]=='7' ||N[3]=='7'){
            cout<<"Yes";
}
    else{
        cout<<"No";
    }
            return 0;}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <cstdlib>
#define ll long long
#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
using namespace std;

int N;
pair<double,string> pr[20];
double ans;

int main(){
        cin >> N;
        FOR(i,0,N){
                cin >> pr[i].first >> pr[i].second;
                if(pr[i].second == "JPY"){
                       ans += pr[i].first;
                }else{
                       ans += pr[i].first*380000; 
                }
        }
        cout << ans << endl;
       
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int mas[111][111];

signed main() {
    int h, w, n;
    cin >> h  >> w;
    cin >> n;
    int x = 0, y = 0, a;
    bool right = true;
    for(int i = 0; i < n; i++) {
        cin >> a;
        while(a) {
            if(right) {
                mas[y][x++] = i;
                if(x == w) y++, x--, right = false;
            }
            else {
                mas[y][x--] = i;
                if(x < 0) y++, x++, right = true;
            }
            a--;
        }
    }

    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cout << mas[i][j]+1 << " \n"[j+1 == w];
        }
    }

    return 0;
}



Measured memory_bytes: 384
from collections import deque
import numpy as np

H,W = map(int,input().split())
maze = [input() for _ in range(H)]

ans = 0
for x in range(H):
    for y in range(W):
        #壁からはスタートできない
        if maze[x][y] == "#":
            continue

        #初期化
        distance = [[0]*W for _ in range(H)]
        #start位置
        stack = deque([[x,y]])

        while stack:
            h,w = stack.popleft()
            for i,j in [[1,0],[-1,0],[0,1],[0,-1]]:
                new_h, new_w = h+i, w+j
                if new_h < 0 or new_w < 0 or new_h >= H or new_w >= W:
                    continue
                elif maze[new_h][new_w] != "#" and distance[new_h][new_w] == 0:
                    distance[new_h][new_w] = distance[h][w]+1
                    stack.append([new_h, new_w])

        #start位置は0で初期化
        distance[x][y] = 0
        ans = max(ans, np.max(distance))

print(ans)

Measured memory_bytes: 12436
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
ll N, A, B, C;
vector<ll> l;

void chmin(int& a, int b)
{
    if (a > b) {
        a = b;
    }
}

int rec(int cur, int a, int b, int c)
{
    // すべての竹を使うかどうか決めた場合
    if (cur == N) {
        // a,b,cのいずれも竹を一本以上使う
        return min({ a, b, c }) > 0 ? abs(a - A) + abs(b - B) + abs(c - C) : INF;
    }

    // 今ある竹を採用しない
    int res = rec(cur + 1, a, b, c);

    // A,B,Cを使う
    // 合成した場合,竹の数を一つ消費して,l[cur]をa or b or cのために使う
    chmin(res, rec(cur + 1, a + l[cur], b, c) + (a ? 10 : 0));
    chmin(res, rec(cur + 1, a, b + l[cur], c) + (b ? 10 : 0));
    chmin(res, rec(cur + 1, a, b, c + l[cur]) + (c ? 10 : 0));

    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> N >> A >> B >> C;
    l.resize(N);
    rep(i, N) { cin >> l[i]; }
    cout << rec(0, 0, 0, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>
using namespace std;

bool compare(vector<int> a, vector<int> b) {
    return a.at(1) < b.at(1);
}

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m; cin >> n >> m;
    vector<vector<int>> discon(m, vector<int>(2));
    for (int i = 0; i < m; i++) {
        cin >> discon.at(i).at(0) >> discon.at(i).at(1);
        discon.at(i).at(0)--; discon.at(i).at(1)--;
    }
    
    sort(discon.begin(), discon.end(), compare);
    
    int ans = 0;
    for (int i = 0; i < n - 1;) {
        bool finish_flag = 1;
        for (int j = 0; j < m; j++) {
            if (i <= discon.at(j).at(0)) {
                i = discon.at(j).at(1);
                ans++;
                finish_flag = 0;
                break;
            }
        }
        if (finish_flag) break;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5760
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		sc.close();

		out.println((N + 1) / 2 - 1);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

struct rest
{
	string s;
	int p, num;
};

bool cmp(const rest& l, const rest& r)
{
	if (l.s == r.s)
	{
		return l.p > r.p;
	}

	return l.s < r.s;
}

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

	vector<rest> rests(N);
	for (int i = 0; i < N; i++)
	{
		cin >> rests[i].s >> rests[i].p;
		rests[i].num = i;
	}

	sort(rests.begin(), rests.end(), cmp);
	
	for (int i = 0; i < N; i++)
	{
		cout << rests[i].num + 1 << endl;
	}


	return 0;
}


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

class Stack
{
private:
    const int MAX = 100;
    int stack[100];
    int sp = 0;

public:
    void push(int num)
    {
        sp++;
        stack[sp] = num;
    }
    int pop()
    {
        sp--;
        return stack[sp + 1];
    }
    bool isEmpty()
    {
        return sp == 0;
    };

    bool isFull()
    {
        return sp < MAX - 1;
    };
};

int main()
{
    Stack stack;
    char s[100];
    int op1, op2, val;
    while (cin >> s)
    {
        if (s[0] == '+')
        {
            op1 = stack.pop();
            op2 = stack.pop();
            val = op2 + op1;
            stack.push(val);
        }
        else if (s[0] == '-')
        {
            op1 = stack.pop();
            op2 = stack.pop();
            val = op2 - op1;
            stack.push(val);
        }
        else if (s[0] == '*')
        {
            op1 = stack.pop();
            op2 = stack.pop();
            val = op2 * op1;
            stack.push(val);
        }
        else
        {
            stack.push(atoi(s));
        }
    }
    val = stack.pop();
    std::cout << val << endl;
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    
    string s,ans;
    cin >> s;
    rep0(i, s.size()){
        if(s[i] != 'B')ans.push_back(s[i]);
        else if(ans.size() > 0)ans.pop_back();
    }
    pf(ans);
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<functional>
#include<vector>
using namespace std;
class city{
public:
    long long fast;
    bool used;
    vector<pair<int,int> > road;
    city():used(false){
        
    }
};

bool compare(pair<long long,int> &a,pair<long long,int> &b){
    return a.first<b.first;
}

int main(){
    int N,M,C;
    cin>>N>>M>>C;
    int a,b,c;
    city map[100001];
    long long distance=0;
    for(int i=0;i<M;++i){
        cin>>a>>b>>c;
        map[a].road.push_back(pair<int,int>(b,c));
        map[b].road.push_back(pair<int,int>(a,c));
        distance+=c;
    }
    priority_queue<pair<long long,int>,vector<pair<long long,int> >,greater<pair<long long,int> > > que;
    
    que.push(pair<long long,int>(0,1));
    while(!que.empty()){
        pair<long long,int> dummy=que.top();que.pop();
        if(map[dummy.second].used)continue;
        map[dummy.second].fast=dummy.first;
        map[dummy.second].used=true;
        for(int i=0,nmax=(int)map[dummy.second].road.size();i<nmax;++i){
            if(map[map[dummy.second].road[i].first].used==false){
                que.push(pair<long long,int>(map[dummy.second].road[i].second+dummy.first,map[dummy.second].road[i].first));
            }
        }
    }
    for(int i=2;i<N+1;++i){
        map[i].used=false;
    }
    vector<pair<long long,int> > line;
    for(int i=2;i<N+1;++i){
        line.push_back(pair<long long,int>(map[i].fast,i));
    }
    sort(line.begin(),line.end(),compare);
    long long ans=distance;
    for(int i=0,nmax=(int)line.size();i<nmax;++i){
        map[line[i].second].used=true;
        for(int j=0,nmax=(int)map[line[i].second].road.size();j<nmax;++j){
            if(map[map[line[i].second].road[j].first].used){
                distance-=map[line[i].second].road[j].second;
            }
        }
        ans=min(ans,line[i].first*C+distance);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long

using namespace std;

int n,m;

int s1[105]={};
int s2[105]={};


int main(){
    while(1){
        int sum1=0;
        int sum2=0;
        
        scanf("%d %d",&n,&m);
        if(n == 0 && m == 0) break;
        for(int i=0;i<n;i++){
            scanf("%d",&s1[i]);
        }
        for(int i=0;i<m;i++){
            scanf("%d",&s2[i]);
        }
        for(int i=0;i<n;i++) sum1 += s1[i];
        for(int i=0;i<m;i++) sum2 += s2[i];
    
        int d = sum1 - sum2;
        if(d & 1){
            printf("-1\n");
        }else{
            sort(s1,s1+n);
            sort(s2,s2+m);

            int judge = 0;
            int a,b;

            for(int i=0;i<m;i++){
                a = s2[i];
                b = a + d/2;
                if(b < 0 || b > 100) continue;
                for(int j=0;j<n;j++){
                    if(b == s1[j]){
                        judge = 1;
                        break;
                    }
                    if(b < s1[j]) break;
                }
                if(judge) break;
            }
            if(judge) printf("%d %d\n",b,a);
            else printf("-1\n");
        }
    }
}


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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n >> m;
    bool ac[n]={};
    int wa[n] ={};
    int acnt=0,wcnt=0;
    for(i=0;i<m;i++){
        int x;
        string s;
        cin>> x >> s;
        if(ac[x-1]==0){
            if(s=="AC"){
                ac[x-1]=1;
            }else{
                wa[x-1]++;
            }
        }
    }
    for(i=0;i<n;i++)if(ac[i]){
        acnt++;
        wcnt+=wa[i];
    }
    cout << acnt << " " << wcnt << endl;
    return 0;
}

Measured memory_bytes: 768
N,M = map(int,input().split())
a = list(map(int,input().split()))
a = sorted(a)
s = sum(a)
cnt = 0
for i in range(N):
    if a[N-1-i] >= s/4/M:
        cnt += 1

if cnt >= M:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int cnt = 0;

void insertionSort(int A[], int N, int g){
    for(int i=g;i<N;++i){
        int v = A[i];
        int j = i-g;
        while(j>=0 && A[j]>v){
            A[j+g] = A[j];
            j -= g;
            ++cnt;
        }
        A[j+g] = v;
    }
}

void shellSort(int a[],int N){
    int m = 1;
    while(1){
        if(pow(2,m)>=N){ --m; break;}
        ++m;
    }
    if(m==0){ m = 1;}
    cout << m <<"\n";
    int G[m];
    for(int i=m;i>=1;--i){
        G[m-i] = pow(2,i)-1;
        if(i>1){ cout << G[m-i] <<" ";}
        else{ cout << G[m-i] << "\n";}
    }
    
    REP(i,m){
        insertionSort(a,N,G[i]);
    }
    cout << cnt <<"\n";
    REP(i,N){
        cout << a[i] <<"\n";
    }
}


int main(){
  int N; cin>>N;
  int a[N]; CINA(a,N);
  shellSort(a,N);
}


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

using namespace std;

int main(){

	int N,T,A;

	cin >> N>>T>>A;

	int H[N+1];

	for(int i=1;i<=N;i++){
		cin >>H[i];
	}	


	int ans=0;
	double dis=999999999;
	
	for(int i=1;i<=N;i++){
	
		double t = T - 0.006*H[i];
		double d=abs(A-t);
		if(dis>d){
			dis = d;
			ans = i;
		
		}
	
	}


	cout <<ans<<endl;


	return 0;

}

Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N, W;
double P[3000];
double DP[3000][1500];

// double dfs(int idx, int r){
//   if (idx == N-1){
//     if (r == W) return P[idx];
//     else return 1.0; 
//   }
//   if (DP[idx][r] > 0) return DP[idx][r];

//   double ans = 0.0;
//   if (r < W) {
//     ans += dfs(idx+1, r+1)*(1-P[idx]);
//   }

//   ans += dfs(idx+1, r)*P[idx];
//   DP[idx][r] = ans;
//   return ans;
// }

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

  cin >> N;
  rep(i, N){
    cin >> P[i];
  }

  W = (N-1)/2; //負ける数の上限
  DP[0][0] = 1;

  rep(i, N){
    rep(j, W+1){
      if (j<W) DP[i+1][j+1] += DP[i][j]*(1-P[i]);
      DP[i+1][j] += DP[i][j]*P[i];
    }
  }

  double ans = 0.0;
  rep(i, W+1) ans += DP[N][i];

  cout << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 35456
s = input()

if s == 'SUN':
    s = 7
if s == 'MON':
    s = 6
if s == 'TUE':
    s = 5
if s == 'WED':
    s = 4
if s == 'THU':
    s = 3
if s == 'FRI':
    s = 2
if s == 'SAT':
    s = 1

print(s)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <deque>
using namespace std;
using P = pair<int,int>;
typedef long long int ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)

int main(){
    double l; cin >> l;
    printf("%.12f",l*l*l/27);
    return 0;
}




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

int main(){
    int n,s=0;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0; i<n-1;i++){
        for(int j=i+1; j<n;j++){
            s=s+a[i]*a[j];
        }
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
C = [[] for i in range(3)]
for i in range(3) :
    C[i] = list(map(int, input().split()))
f = True
for i0 in range(3) :
    for i1 in range(3) :
        for j0 in range(3) :
            for j1 in range(3) :
                if C[i0][j0] - C[i1][j0] != C[i0][j1] - C[i1][j1] or C[i0][j0] - C[i0][j1] != C[i1][j0] - C[i1][j1] :
                    f = False
print("Yes" if f else "No")

Measured memory_bytes: 3064
def solve():
    def backtrack(nums, cur_state, permutations):
        if not nums:
            permutations[' '.join(cur_state)] = len(permutations)
        for i in range(len(nums)):
            cur_state.append(nums[i])
            backtrack(nums[:i]+nums[i+1:], cur_state, permutations)
            cur_state.pop()

    num = int(input())
    P = str(input())
    Q = str(input())
    # print(num, P, Q)
    nums = [str(i) for i in list(range(1, num+1))]
    permutations = {}
    backtrack(nums, [], permutations)
    # print(permutations)
    print(abs(permutations[Q]-permutations[P]))


if __name__ == "__main__":
    solve()

Measured memory_bytes: 13856
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define bit(k) (1LL<<(k))
typedef long long ll;

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

const int INF = 1e9;
const ll INFLL = 1e18;
const ll MOD = 1e9+7;
const double PI = acos(-1.0);

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

/*------------------------------------/
for library*/

/*------------------------------------*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N,q;
    cin>>N>>q;
    vector<ll> a(N);
    rep(i,N)cin>>a[i];
    sort(all(a));
    rep(i,q){
        ll l,r;
        cin>>l>>r;
        int ans = upper_bound(all(a),r) - lower_bound(all(a),l);
        cout<<ans<<endl;
    }
}


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

int main(){
    int t, n; cin >> t >> n;
    int sum = 0;
    for(int i=0; i<n; i++){
        int x; cin >> x;
        sum+=x;}
    if(sum>t) cout << "-1";
    else cout << t-sum;}

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

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

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)



vector<bool> gen_sosuu(vector<bool> sosuu){
  int size = sosuu.size();
  REP(i,size){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(size)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<size;j++){
      sosuu[i*j] =false;
    }
  }
  return sosuu;
}

int a,b;

int main(){
  cin >> a>>b;
  if(a<=b){
    cout << a << endl;
  }else{
    cout << a-1 << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define INF 9999999

using namespace std;

int n, d[101][101];

void warshall_floyd(void){

  for( int k = 1; k <= n; k++ )
    for( int i = 1; i <= n; i++ )
      for( int j = 1; j <= n; j++ ){
	d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
}

 
int main(void){

    int m, s, g1, g2, b1, b2, c;

    while(cin >> n >> m >> s >> g1 >> g2 ){
      if( n == m && m == s && s == g1 && g1 == g2 && g2 == 0 ) break;

        for( int i = 0; i <= n; i++ ){
            for(int j = 0; j <= n; ++j){
                d[i][j] = INF;
            }
            d[i][i] = 0;
        }
         
        for( int i = 0; i < m; i++ ){
	  cin >> b1 >> b2 >> c;
            d[b1][b2] = c;
        }

	warshall_floyd();
                  
        int ans = INF;
        for( int i = 1; i <= n; i++ ){
            ans = min(ans, d[s][i] + d[i][g1] + d[i][g2]);
        }
	cout << ans << endl;
    }
}

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

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  double an;
  
  //角度求める
  //長針
  double al = m * M_PI /30.0;
  //短針
  double as = M_PI * (60.0 * h + m) / 360;
  an = abs(al - as);
  
  double x2;
  x2 = pow(a, 2) + pow(b, 2) - (2 * a * b *cos(an));
  double x = pow(x2, 0.5);
  
  cout << fixed << setprecision(20) << x << endl;
}



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


int main() {

	int N;
	int total;
	int ten_thousand = -1, thousand = -1, hundred = -1;

	cin >> N;
	cin >> total;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; i + j <= N; j++) {
			int k = N - i - j;
			bool toflag = (total == 10000 * i + 5000 * j + 1000 * k);
			if (toflag) {
				ten_thousand = i; thousand = j; hundred = k;
			}
		}
	}

	cout << ten_thousand<< ' ' << thousand << ' '<< hundred;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
vector <int> edges[1000];
int match[1000];
bool used[1000];

void add_edge(int u, int v){
    edges[u].push_back(v);
    edges[v].push_back(u);
}

bool dfs(int v){
    used[v] = true;
    for(int i = 0; i < edges[v].size(); i++){
        int u = edges[v][i];
        int w = match[u];
        if(w < 0 || (!used[w] && dfs(w))){
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(int N){
    int res = 0;
    memset(match, -1, sizeof(match));
    for(int v = 0; v < N; v++){
        if(match[v] < 0){
            memset(used, 0, sizeof(used));
            if(dfs(v)){
                res ++;
            }
        }
    }
    return res;
}

void init(int N){
    for(int i = 0; i < N; i++){
        edges[i].clear();
        match[i] = 0;
        used[i] = false;
    }
}

int gcd(int m, int n){
    if(m < n){
        return gcd(n, m);
    }
    if(n == 0){
        return m;
    } 
    return gcd(n, m % n);
}

int b[500];
int r[500];
int main(void){
    int m;
    int n;
    while(true){
        cin >> m >> n;
        if(m == 0 && n == 0){
            break;
        }
        for(int i = 0; i < m; i++){
            cin >> b[i];
        }
        for(int i = 0; i < n; i++){
            cin >> r[i];
        }

        init(m + n);
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                if(gcd(b[i], r[j]) != 1){
                    add_edge(i, m + j);
                }
            }
        }
        cout << bipartite_matching(m) << endl;
    }
    return 0;
}


Measured memory_bytes: 5004
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x[] = new int[5];
    for(int i=0 ; i<5 ; i++){
      x[i] = sc.nextInt();
    }
    for(int i=0 ; i<5 ; i++){
      if(x[i] == 0){
        System.out.println(i+1);
        break;
      }
    }
  }
}


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

int main() {
  int dice[6];
  for (int i=0; i<6; i++) cin >> dice[i];
  string s;
  cin >> s;

  // dice[0] が常に上
  for (int i=0; i<s.size(); i++) {
    int temp = dice[0];
    switch(s[i]) {
    case 'E':
      dice[0] = dice[3];
      dice[3] = dice[5];
      dice[5] = dice[2];
      dice[2] = temp;
      break;
    case 'W':
      dice[0] = dice[2];
      dice[2] = dice[5];
      dice[5] = dice[3];
      dice[3] = temp;
      break;
    case 'S':
      dice[0] = dice[4];
      dice[4] = dice[5];
      dice[5] = dice[1];
      dice[1] = temp;
      break;
    case 'N':
      dice[0] = dice[1];
      dice[1] = dice[5];
      dice[5] = dice[4];
      dice[4] = temp;
      break;
    }
  }

  cout << dice[0] << endl;

  return 0;
}



Measured memory_bytes: 3204
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	ll a, b, d, sum = 0, ans;
	cin >> a >> b;
	d = b - a;
	repi(i, 1, d) {
		sum += i;
	}
	ans = sum - a;
	wrln(ans);
	return 0;
}


Measured memory_bytes: 256