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

typedef pair<pair<double,int>,pair<int,int> > P;

class road{
public:
  int x,y,d,c;
};


int main(){
  int n,m,s,g;

  for(;;){
    scanf("%d %d",&n,&m);
    if(!n && !m)break;
    scanf("%d %d",&s,&g);

    road r[1000];
    double t[31][31][31];
    bool v[31][31][31];

    for(int i=0;i<m;i++)scanf("%d %d %d %d",&r[i].x,&r[i].y,&r[i].d,&r[i].c);
    
    for(int i=0;i<=n;i++)
      for(int j=0;j<=n;j++)
	for(int k=0;k<=30;k++){
	t[i][j][k] = 1e10;
	v[i][j][k] = false;
      }

    t[s][0][0] = 0.0;
    priority_queue<P,vector<P>,greater<P> > q;
    q.push(P(pair<double,int>(0.0,s),pair<int,int>(0,0)));

    while(q.size()){
      P p = q.top();q.pop();

      double time = p.first.first;
      int now,prv,speed;
      now = p.first.second;
      prv = p.second.first;
      speed = p.second.second;

      if(v[now][prv][speed])continue;
      v[now][prv][speed] = true;
      //printf("%d %d %d\n",now,prv,speed);

      for(int i=0;i<m;i++){
	if(r[i].x == now && r[i].y != prv){
	  for(int dif=-1;dif<=1;dif++){
	    if(speed+dif>0 &&  speed+dif<=r[i].c){
	      if(!v[r[i].y][now][speed+dif]){
		if(t[r[i].y][now][speed+dif] > time+(double)r[i].d/(speed+dif)){
		  t[r[i].y][now][speed+dif] = time+(double)r[i].d/(speed+dif);
		  q.push(P(pair<double,int>(t[r[i].y][now][speed+dif],r[i].y),pair<int,int>(now,speed+dif)));
		}
	      }
	    }
	  }
	}else if(r[i].y == now && r[i].x != prv){
	  for(int dif=-1;dif<=1;dif++){
	    if(speed+dif>0 && speed+dif<=r[i].c){
	      if(!v[r[i].x][now][speed+dif]){
		if(t[r[i].x][now][speed+dif] > time+(double)r[i].d/(speed+dif)){
		  t[r[i].x][now][speed+dif] = time+(double)r[i].d/(speed+dif);
		  q.push(P(pair<double,int>(t[r[i].x][now][speed+dif],r[i].x),pair<int,int>(now,speed+dif)));
		}
	      }
	    }
	  }
	}
      }
    }
    /*
    for(int i=0;i<31;i++){
      for(int j=1;j<=n;j++)printf("%3.3lf ",t[j][i]);
      putchar('\n');
    }
    */
    double ans = 1e10;
    for(int i=0;i<=n;i++)ans = min(ans,t[g][i][1]);
    if(ans==1e10)printf("unreachable\n");
    else printf("%.4lf\n",ans);
  }
}

Measured memory_bytes: 2092
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, w; char a; cin >> n >> w;
	char test[60][60] = { '#' };
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= w; i++) {
			cin >> a;
			test[h][i] = a;
		}
	}
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= w; i++) {
			if (test[h][i] == '#' && test[h][i - 1] == '.') {
				if (test[h - 1][i] == '.' && test[h + 1][i] == '.' && test[h][i + 1] == '.') {
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	int n=0;
	int s[105];
	int i=0;
	int j=0;
	int k=0;
	int c=0;
	int a=0;
	int m=0;
	int f[10];
	memset(s,0,sizeof(s)); 
	cin>>n;
	for(i=0;i<n;i++){
		cin>>c>>a>>m;
		f[0]=min(c,a);
		f[1]=min(f[0],m);
		s[i]+=f[1];
		a-=f[1];
		c-=f[1];
		if(c>2*a){
			s[i]+=a;
			c-=2*a;
		}else{
			f[0]=c/2;
			c=0;
			s[i]+=f[0];
		}
		f[0]=c/3;
		s[i]+=f[0];
	}
	for(i=0;i<n;i++){
		cout<<s[i]<<endl;
	}
}              

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int cnt=0;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int ans=1;
  for(int i=0;i<n;i++){
    if(a.at(i)==ans){
      ans++;
    }
    else{
      cnt++;
    }
  }
  if(cnt==n){
    cout << "-1" << endl;
  }
  else {
    cout << cnt << endl;
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>


using namespace std;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	int count = 0;

	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			if (j != i) {
				if (a[j] == a[i]) {
					count++;
				}
			}
		}


	}
	
	switch (count)
	{
	case 6:
		count = 1;
		break;
	case 2:
		count = 2;
		break;
	case 0:
		count = 3;
		break;

	default:
		break;
	}

	std::cout <<  count << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); 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 FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<lli> A(N);
    vector<pair<lli, lli>> BC(M);
    REP(i, N)
    {
        cin >> A[i];
    }
    sort(ALL(A));
    REP(i, M)
    {
        cin >> BC[i].second >> BC[i].first;
    }
    BC.emplace_back(-1, N);
    sort(ALL(BC));
    reverse(ALL(BC));

    /*REP(i, M + 10)
    {
        cout << BC[i].first << " " << BC[i].second << "\n";
    }*/
    lli ans = 0, index = 0, counter = 0;
    REP(i, N)
    {
        if (index == BC[counter].second)
        {
            index -= BC[counter].second;
            counter++;
        }
        ans += max(A[i], BC[counter].first);
        index++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
	int N;
	long Z, W;
	cin >> N >> Z >> W;
	vector <long> A(N);
	for (int i = 0; i < N; i++) cin >> A.at(i);
	long ans;
	if (N == 1)
		ans = abs(A.at(0) - W);
	else
		ans = max(abs(A.at(N-1) - W), abs(A.at(N-1) - A.at(N-2)));
	cout << ans << endl;
}


Measured memory_bytes: 256
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let h: String = sc.read();
    let mut ok = true;
    if h.len() % 2 == 1 {
        ok = false;
    }
    for i in 0..h.len() {
        let c = h.chars().nth(i).unwrap();
        if i % 2 == 0 {
            if c != 'h' {
                ok = false
            }
        } else {
            if c != 'i' {
                ok = false
            }
        }
    }

    if ok {
        println!("{}", "Yes")
    } else {
        println!("{}", "No")
    }

}

Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[] s = new String[h + 2];
        String tmp = "";
        for (int i = 0; i < w + 2; i++) {
            tmp += ".";
        }
        s[0] = tmp;
        s[s.length - 1] = tmp;
        for (int i = 1; i < s.length - 1; i++) {
            s[i] = "." + sc.next() + ".";
        }
        boolean ok = true;
        for (int i = 1; i < s.length - 1; i++) {
            for (int j = 1; j < s[i].length() - 1; j++) {
                if (s[i].charAt(j) == '#') {
                    if (!(s[i - 1].charAt(j) == '#'
                    || s[i + 1].charAt(j) == '#'
                    || s[i].charAt(j - 1) == '#'
                    || s[i].charAt(j + 1) == '#')) {
                        ok = false;
                    }
                }
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 39180
use proconio::input;

fn main() {
    input! {
        n: u32,
        x: u32,
        t: u32,
    }
    let ans = n / x;
    if n % x != 0 {
        println!("{}", (ans + 1) * t);
    } else {
        println!("{}", ans * t);
    }
}


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

#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;

struct bipartiteGraph {
    int L, R;
    vector<vector<int>> adj;
    vector<int> mate;
    bipartiteGraph(int L, int R) : L(L), R(R), adj(L+R), mate(L+R, -1) { }
    void add_edge(int u, int v) {
        adj[u].push_back(v+L);
        adj[v+L].push_back(u);
    }
    int maximum_matching() {
        vector<int> visited(L);
        function<bool(int)> augment = [&](int u) { // DFS
            if (visited[u]) return false;
            visited[u] = true;
            for (int w: adj[u]) {
                int v = mate[w];
                if (v < 0 || augment(v)) {
                    mate[u] = w;
                    mate[w] = u;
                    return true;
                }
            }
            return false;
        };
        int match = 0;
        for (int u = 0; u < L; ++u) {
            fill(visited.begin(),visited.end(), 0);
            if (augment(u)) ++match;
        }
        return match;
    }
    int lPartner(int l){return mate[l]-L;}
    int rPartner(int r){return mate[r+L];}
};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll x[N],y[N];
  for(ll i=0;i<N;i++){
    cin>>x[i]>>y[i];
  }
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  ll ans = INF;
  for(ll k=1;k<N;k++){
    ll p=x[k]-x[0],q=y[k]-y[0];
    bipartiteGraph g(N,N);
    for(ll i=0;i<N;i++){
      for(ll j=0;j<N;j++)if(i!=j){
        if(p==x[j]-x[i]&&q==y[j]-y[i]){
          g.add_edge(i,j);
        }
      }
    }
    ans = min(ans,N-g.maximum_matching());
  }
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int n , k , sum = 1 ;
  cin >> n >> k ;
  
  for ( int i = 0 ; i < n ; i++ ) {
   	if ( sum <= k ) { 
    	sum *= 2 ;
    }
    else if ( sum > k ) {
    	sum += k ;
    }
  } 
  cout << sum << endl;
}

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

int main() {
  vector<int> pri(100010, 1), like(100010), sum(100010);
  for(int i = 2; i * 2 <= 100010; i++){
    for(int j = i + i; j < 100010; j += i) pri.at(j) = 0;
  }
  for(int i = 3; i < 100010; i++){
    if(!pri.at(i)) continue;
    if(pri.at((i+1)/2)) like.at(i) = 1;
  }
  int cnt = 0;
  for(int i = 0; i < 100010; i++){
    if(like.at(i)) cnt++;
    sum.at(i) = cnt;
  }
  
  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    int l, r;
    cin >> l >> r;
    cout << sum.at(r) - sum.at(l-1) << endl;
  }
}

Measured memory_bytes: 4500
t=int(input())
import math
a=list(map(int,input().strip().split()))
q=int(input())
h=[0]*(1000000+1)
sumi=0
for i in range(len(a)):
    h[a[i]]+=1
    sumi+=a[i]
 
for i in range(q):
    b,c=map(int,input().strip().split())
    #print(h)
    sumi+=h[b]*(c-b)
    h[c]+=h[b]
    h[b]=0
    #print(h)
    print(sumi)
        
        
        
    #a=list(map(int,input().strip().split()))
    
    
        
        
    
        
        
            
        
    


Measured memory_bytes: 91008
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    vector<int> B(N + 1);
    rep(i, N) B[A[i]]++;
    ll sum = 0;
    rep(i, 1, N + 1) sum += (ll)B[i] * (B[i] - 1) / 2;

    rep(i, N) {
        write(sum - B[A[i]] * (B[A[i]] - 1) / 2 + (B[A[i]] - 1) * (B[A[i]] - 2) / 2);
    }
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <string.h>
int abs(int b)
{
    if(b>=0)
        return b;
    else
        return -b;
}
int a[105];
int main()
{
    int sum1=0,n,i,sum2=0,k,c,minn=10001;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        sum1=sum1+a[i];
    }
        for(i=n;i>=1;i--)
        {
          sum2=sum2+a[i];
          k=sum1-sum2;
          c=abs(sum2-k);
          if(c<minn)
          {
              minn=c;
          }
        }
    printf("%d\n",minn);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cmath>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(int i = a; i < b; i++)
#define repj(a,b)for(int j = a; j < b; j++)
#define pii pair<int,int>

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


int main() {
	int n, x, ans = 1, sum = 0; cin >> n >> x;
	repi(0, n) {
		int tmp; cin >> tmp;
		sum += tmp;
		if (sum <= x)ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    map<string, int> xmap;
    int n;
    cin >> n;
    int i;
    int ans(0);
    rep(i, n) {
        string s;
        cin >> s;
        if (xmap[s] == 0) {
            ans++;
        }
        xmap[s]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 19196
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 105;
int main()
{
	queue<ll>q;
	for(int i=1;i<10;i++)q.push(i);
	int k,cnt=0;ll t;
	cin>>k;
	do{
		t=q.front();
		q.pop();
		if(t%10)q.push(t*10+t%10-1);
		q.push(t*10+t%10);
		if(t%10!=9)q.push(t*10+t%10+1);
		cnt++;
	}while(cnt!=k);
	cout<<t;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max({ a,b,c }) * 9 + a + b + c << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    
    int n, a, max, min, i;
    long long int sum;
    sum = 0;
    max = -1000000;
    min = 1000000;
    
    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        scanf("%d", &a);
        if (max <= a) max = a;
        if (min >= a) min = a;
        sum = sum + a;
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 1812
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2, degrees
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
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 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)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007

s = S()
n = len(s)
ans = n
for i in range(n - 1):
    if s[i] != s[i + 1]:
        ans = min(ans, max(i + 1, n - i - 1))


print(ans)


Measured memory_bytes: 41072
while True:
  x=[0 for i in range(7)]
  n=int(input())
  if n==0:
    break
  for i in range(n):
    a=int(input())
    if 0<=a<10:
      x[0]+=1
    elif 10<=a<20:
      x[1]+=1
    elif 20<=a<30:
      x[2]+=1
    elif 30<=a<40:
      x[3]+=1
    elif 40<=a<50:
      x[4]+=1 
    elif 50<=a<60:
      x[5]+=1
    else:
      x[6]+=1
  for i in range(7):
    print(x[i])


Measured memory_bytes: 5620
#include<bits/stdc++.h>
#include<bitset>
using  namespace std;
#define ll long long
#define pb push_back
#define sc second
#define fr first
#define mp make_pair
const int N = 3e5 + 10, Max = 2e5 + 10;
const ll  MOD = 1e9 + 7, OO = 1e9;
int monster[N] , hero[N];
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n + 1; ++i) {
		cin >> monster[i];
	}
	for (int i = 1; i <= n; ++i)
		cin >> hero[i];
	ll ans = 0;
	for (int i = 2; i <= n + 1; ++i) {
		int x = min(hero[i - 1], monster[i - 1]);
		hero[i - 1] -= x;
		monster[i - 1] -= x;
		ans += x;
		x = min(hero[i - 1], monster[i]);
		hero[i - 1] -= x;
		monster[i] -= x;
		ans += x;
	}
	cout << ans << endl;
}


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

using namespace std;
const int INF = 0x3f3f3f3f;


int main() {
	int N, K;
	cin >> N >> K;
	vector<int> h(N), dp(N);
	for (int i = 0; i<N; i++){
		cin >> h[i];
		dp[i] = INF;
	}
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i<N; i++){
		for (int k = 1; k<K+1; k++){
			if (i-k>=0){
				dp[i] = min(dp[i], dp[i-k]+abs(h[i]-h[i-k]));
			}
		}
	}
	cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
  string s;
  cin >> s;
  if (s=="Sunny") cout << "Cloudy" << endl;
  else if (s== "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=2e6+9,mod=998244353;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	int n,m,fac[N],ifac[N];
	inline int C(int _n,int _m){
		if(_n<0 || _m<0 || _n<_m) return 0;
		return 1LL*fac[_n]*ifac[_m]%mod*ifac[_n-_m]%mod;
	}
	int main(){
		n=read<int>(),m=read<int>();
		if(n<m) swap(n,m);
		fac[0]=ifac[0]=1;
		for(int i=1;i<=n+m;i++) fac[i]=1LL*fac[i-1]*i%mod;
		ifac[n+m]=qpow(fac[n+m],mod-2);
		for(int i=n+m-1;i>=1;i--) ifac[i]=1LL*ifac[i+1]*(i+1)%mod;
		
		int ans=0;
		for(int i=1;i<=m;i++)
			ans=(1LL*C(n-i+m-i,m-i)*C(2*i,i)+ans)%mod;
		ans=1LL*ans*qpow(C(n+m,n),mod-2)%mod;
		printf("%d\n",add(1LL*ans*(mod+1)/2%mod,n));
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 11596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
bool isprime(int x){
  for(int i = 2; i*i <= x; i++){
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  int X;
  cin >> X;
  int num = X;
  int ans = 0;
  while(!isprime(num)) num++;
  cout << num << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

class Main
{
   public static void main(String[] args) throws IOException
   {

      BufferedReader br =
       new BufferedReader(new InputStreamReader(System.in));

      String str = br.readLine();
      int x = Integer.parseInt(str);

      //System.out.println( x^3 );  // ^???Java??§???????????§?????????XOR???????????????
      System.out.println( x*x*x );           // <= ??£?§£
      //System.out.println( Math.pow(x.3) ); // Math.pow ???double???????????????
      //System.out.println( (int)Math.pow(x.3) ); // <= ??£?§£

    }
}

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

#define INF (1<<29)

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> R(r);
    for (int i = 0; i < r; i++) {
        int a; cin >> a;
        R[i] = a - 1;
    }
    int M[209][209];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            /*
            if (i == j) {
                M[i][j] = 0;
            } else {
            */
            if (i != j) {
                M[i][j] = INF;
            }
        }
    }

    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        if (M[a][b] > c) {
            M[a][b] = M[b][a] = c;
        }
    }

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

    sort(R.begin(), R.end());

    long long ans = 1e9;
    do {
        long long sum = 0;
        for (int i = 0; i < (r-1); i++) {
            sum += M[ R[i] ][ R[i+1] ];
        }
        ans = min(sum ,ans);
    } while ( next_permutation(R.begin(), R.end()) );

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    
    int n; cin >> n;
    int a[n];
    int sum = 0;
    for(int i=0;i<n;i++){
    	cin >> a[i];
		sum += a[i];
	}
	
       sort(a,a+n);

	if(sum%10 != 0){
		cout << sum;
		return 0;
	}
 
	for(int i=0;i<n;i++){
		sum-=a[i];
		if(sum%10){
			cout << sum;
			return 0;
		}
		else{
			sum+=a[i];
		}
	}
	
	cout <<0;
	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 MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

ll out = 0;

void abset(ll a, ll n)
{
    if(a*a >= n)
        return;
    ll mult = a + 1;
    out++;
    while (a * mult < n)
    {
        out += 2;
        mult++;
    }
    return;
}

int main(){
    ll n;
    cin >> n;
    for (ll i = 1; i < n;i++)
    {
        abset(i, n);
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

int n;
double memo[330][330][330];
bool flg[330][330][330];

double rec(int i, int j, int k){
    if(i==0 && j==0 && k==0) return 0;
    if(flg[i][j][k]) return memo[i][j][k];
    flg[i][j][k]=true;

    double res=0;
    if(i>0) res += i*rec(i-1, j, k);
    if(j>0) res += j*rec(i+1, j-1, k);
    if(k>0) res += k*rec(i, j+1, k-1);
    res += n;
    res /= (double)(i+j+k);

    return memo[i][j][k]=res;
}

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

    cin >> n;
    int cnt1=0, cnt2=0, cnt3=0;

    rep(i, n){
        int a; cin >> a;
        if(a==1) ++cnt1;
        if(a==2) ++cnt2;
        if(a==3) ++cnt3;
    }

    cout << setprecision(16) << rec(cnt1, cnt2, cnt3) << endl;

    return 0;
}


Measured memory_bytes: 288896
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(void) {
	long long int n, d, i, c = 0;
	double x, y, z;

	scanf("%lld %lld", &n, &d);

	for (i = 0; i < n; i++) {
		scanf("%lf %lf", &x, &y);
		
		z = x * x + y * y;
		z = sqrt(z);

		if (z <= d) {
			c++;
		}
	}
	printf("%d", c);
}

Measured memory_bytes: 2220
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);

int __inf_ignore(){
	int t = inf<int>;
	return t;
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int N;
vector<Int> a;

void solve(){
	Int max_abs = -1;
	int max_index = -1;
	REP(i,N){
		if(max_abs < abs(a[i])){
			max_abs = abs(a[i]);
			max_index = i;
		}
	}
	cout<<N*2-1<<endl;
	if(a[max_index]>=0){
		for(int i = 0;i < N;i++){
			cout<<max_index+1<<" "<<i+1<<endl;
		}
		for(int i = 0;i < N - 1;i++){
			cout<<i + 1<<" "<<i + 2<<endl;
		}
	}else{
		for(int i = 0;i < N;i++){
			cout<<max_index+1<<" "<<i+1<<endl;
		}
		for(int i = N-1;i >= 1;i--){
			cout<<i + 1<<" "<<i<<endl;
		}
	}
}
//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
	a.assign(N,Int());
	for(int i = 0 ; i < N ; i++){
		cin >> a[i];
	}
	solve();
	return 0;
}
//}}}

Measured memory_bytes: 256
using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramA a = new ProgramA();
            a.main();//実行する

        }

    }
    //ABC178
    class ProgramA
    {
        public void main()
        {
            //入力
            string s = Console.ReadLine();
            //30以上ならYes、それ以外はNoを出力
            if(s[s.Length  -1] == 's')
                Console.WriteLine(s + "es");
            else
                Console.WriteLine(s + "s");


        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力

            string[] s = Console.ReadLine().Split(' ');
            long a = long.Parse(s[0]);
            long b = long.Parse(s[1]);
            long c = long.Parse(s[2]);
            long d = long.Parse(s[3]);
            long max1 = Math.Max(a * c, a * d);
            long max2 = Math.Max(b * c, b * d);

            Console.WriteLine(Math.Max(max1, max2));

        }
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            long n = long.Parse(Console.ReadLine());
            long MOD = 1000000000 + 7;

            long ans = (modpow(10, n, MOD) + modpow(8, n, MOD) - 2 * modpow(9, n, MOD) % MOD)% MOD;

            Console.WriteLine((ans + MOD) % MOD);


        }

        static long modpow(long a, long n, long MOD)
        {
            if (n == 0)
                return 1;
            if (n % 2 == 0)
            {
                long temp = modpow(a, n / 2, MOD);
                return temp * temp % MOD;
            }

            return a * modpow(a, n - 1, MOD) % MOD;
        }
    }

    class ProgramD
    {
        public void main()
        {

        }
            
    }

    class ProgramE
    {

        public void main()
        {

        }


    }

}






Measured memory_bytes: 25908
N = int(input())
txy = [0]*(N+1)
txy[0] = [0, 0, 0]
for i in range(1, N + 1):
    txy[i] = [int(i) for i in input().split()]

for i in range(1, N + 1):
    dis = abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2])
    time = txy[i][0] - txy[i-1][0]
    if time < dis or (time - dis) % 2 != 0:
        print('No')
        break
else:
    print('Yes')

Measured memory_bytes: 21156
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4020
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    final String LINE_SPR = System.getProperty("line.separator");
    final int BIG_MOD = 1000000007;

    void run() throws Exception {
        while(true) {
            int n = ni();
            if(n == 0)
                return;

            Map<Character, Character> map = new HashMap<Character, Character>();
            for(int i = 0; i < n; i++) {
                String[] chars = ns().split(" ");
                map.put(chars[0].charAt(0), chars[1].charAt(0));
            }

            int m = ni();
            StringBuffer sb = new StringBuffer();
            for(int i = 0; i < m; i++) {
                char c = ns().charAt(0);
                if(map.containsKey(c))
                    sb.append(map.get(c));
                else
                    sb.append(c);
            }

            System.out.println(sb.toString());
        }
    }


    /*
     * Templates
     */
    void dumpObjArr(Object[] arr, int n) {
        for(int i = 0; i < n; i++) {
            System.out.print(arr[i]);
            if(i < n - 1)
                System.out.print(" ");
        }
        System.out.println("");
    }

    void dumpObjArr2(Object[][] arr, int m, int n) {
        for(int j = 0; j < m; j++) 
            dumpObjArr(arr[j], n);
    }

    int ni() throws Exception {
        return Integer.parseInt(br.readLine().trim());
    }

    long nl() throws Exception {
        return Long.parseLong(br.readLine().trim());
    }

    String ns() throws Exception {
        return br.readLine();
    }

    boolean isPrime(int n) {
        for(int i=2;i<n;i++) {
            if(n%i==0)
                return false;
        }
        return true;
    }

    int getPrime(int n) {
        List<Integer> primes = new ArrayList<Integer>();
        primes.add(2);
        int count = 1;

        int x = 1;
        while(primes.size() < n) {
            x+=2;
            int m = (int)Math.sqrt(x);
            for(int p : primes) {
                if(p > m) {
                    primes.add(x);
                    break;
                }

                if(x % p == 0) 
                    break;
            }
        }

        return primes.get(primes.size() - 1);
    }

    void gcjPrint(String str, int t) {
        System.out.println("Case #" + t + ": " + str);
    }

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

Measured memory_bytes: 36400
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int A, B, C;
  cin >> A >> B >> C;

  if(A == B && B == C && A%2 == 0){
    cout << "-1" << endl;
  }else{
    int cnt = 0;
    while(A%2 == 0 && B%2 == 0 && C%2 == 0){
      int a = B/2 + C/2;
      int b = A/2 + C/2;
      int c = B/2 + C/2;
      A = a;
      B = b;
      C = c;
      cnt++;
    }
    cout << cnt << endl;
  }
}

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

int n, k;

long long int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &k);

  for (int b = 1; b <= n; ++b) {
    int maxnum = b - 1;

    int cand_part = (maxnum >= k) ? maxnum - k + 1 : 0;

    int part_num = (n + 1) / b;
    int remain = (n + 1) % b;

    if (remain > 0) {
      int remain_maxnum = n % b;
      int remain_cand_part = (remain_maxnum >= k) ? remain_maxnum - k + 1 : 0;
      ans += cand_part * part_num + remain_cand_part;
    }
    else {
      ans += cand_part * part_num;
    }
  }

  if (k == 0) ans -= n;

  printf("%lld\n", ans);

	return 0;
}


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

   typedef long long ll;
   typedef pair<ll, ll> Pii;
   typedef vector<ll> Vi;
   typedef vector<Vi> VVi;

   const double EPS = (1e-7);
   const ll INF =(1e13);
   const double PI = (acos(-1));
   const ll MOD = ll(1e9) + 7;

   #define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
   #define REPR(i, n) for(ll i = n; i > -1; i--)
   #define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
   #define ALL(x) (x).begin(),(x).end()
   #define SORT(x) sort((x).begin(), (x).end())
   #define RSORT(x) sort((x).rbegin(), (x).rend())
   #define REVERSE(x) reverse((x).begin(), (x).end())
   #define SZ(x) ((ll)(x).size())
   #define pb push_back
   #define mp make_pair

   //chmax(a, b): a>bならaをbで更新　更新したときにtrueを返す
   //chmin(a, b): a<bならaをbで更新　更新したときにtrueを返す
   template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
   template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

   #define dump(x) cerr<< #x << "= " << (x) << endl;

   ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
   ll pow(ll a, ll b){if (b == 0) return 1; else if (b % 2 == 0) return pow(a * a, b / 2); else return pow(a * a, b / 2) * a;}
   ll pow(ll a, ll b, ll m){if (b == 0) return 1; else if (a == 0) return 0; else if (b % 2 == 0) return (pow((a * a) % m, b / 2, m) % m); else return (pow((a * a) % m, b / 2, m) * a) % m;}
   ll residue(ll a, ll m){return ((a % m) + m) % m;};

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

struct event{
  int type, time, dist ;
};
int main(){
  int n, q; cin >> n >> q;
  vector<event> E(2 * n);
  vector<int> d(q);
  set<int> s;
  for(int i = 0; i < n; i++){
    int s, t, x; cin >> s >> t >> x;
    E[2 * i] = event{0, s - x, x};
    E[2 * i + 1] = event{1, t - x, x};
  }
  for(int i = 0; i < q; i++) cin >> d[i];
  sort(E.begin(), E.end(), [](const event& a, event& b){return (a.time == b.time) ? (a.type > b.type) : (a.time < b.time);});
  //for(auto e : E) printf("e = {%d, %d, %d}\n", e.type, e.time, e.dist);
  auto e = E.begin();
  for(int i = 0; i < q; i++){
    while(e->time <= d[i] && e != E.end()){
//      printf("d[i] = %d, e = {%d, %d, %d}\n", d[i], e->type, e->time, e->dist);
      if(e->type == 0) s.insert(e->dist);
      else s.erase(e->dist);
      e++;
    }
    cout << ((s.empty()) ? -1 : *(s.begin())) << endl;
  }
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
// 最大公約数を求める関数gcd
int gcd(int x, int y){
int r;
    while((r= x % y)!=0){x=y; y=r;}
    return y;
}
// 最小公倍数を求める関数lcm
int lcm(int x, int y){return (x*y/gcd(x,y));}
 
int main(){
  int A,B,K;
  cin >> A >> B >> K;
  int count=0;
  for(int i=100;i>=1;i--){
    if(A%i==0 && B%i==0)count++;
    if(count==K){cout << i << endl; return 0;}
  }
}

Measured memory_bytes: 256
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let a_price = parse_word::<i32>();
    let b_price = parse_word::<i32>();
    let ab_price = parse_word::<i32>();

    let a_num = parse_word::<i32>();
    let b_num = parse_word::<i32>();

    let calc_price = |a, b, ab| a * a_price + b * b_price + ab * ab_price;

    let min_price = (0..(cmp::max(a_num, b_num) + 1))
        .map(|ab_buy_half| {
            let a_buy = cmp::max(0, a_num - ab_buy_half);
            let b_buy = cmp::max(0, b_num - ab_buy_half);
            calc_price(a_buy, b_buy, ab_buy_half * 2)
        })
        .min()
        .unwrap();

    println!("{}", min_price);
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define mod 1000000007
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";


int main(){
  string S1,S2;cin>>S1>>S2;
  int s1_l=S1.length(), s2_l=S2.length();
  int dp[s1_l+1][s2_l+1];
  REP(s1,0,s1_l+1)dp[s1][0]=s1;
  REP(s2,0,s2_l+1)dp[0][s2]=s2;

  REP(s1,1,s1_l+1)REP(s2,1,s2_l+1){dp[s1][s2]=
  min({dp[s1-1][s2]+1,dp[s1][s2-1]+1,dp[s1-1][s2-1]+((S1[s1-1]==S2[s2-1])?0:1)});
  //print((S1[s1]==S2[s2]))
  }
  print(dp[s1_l][s2_l])
}


Measured memory_bytes: 7084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BipartiteMatching
{
    class BipartiteMatching
    {
        readonly int n;

        Dictionary<int, List<int>> G;
        int[] match;
        bool[] used;

        public BipartiteMatching(int V)
        {
            n = V;

            G = new Dictionary<int, List<int>>();
            for (int i = 0; i < n; i++) G.Add(i, new List<int>());
        }

        public void AddEdge(int u, int v)
        {
            G[u].Add(v);
            G[v].Add(u);
        }

        public int MaxmimumMatching()
        {
            int ret = 0;

            match = Enumerable.Repeat(-1, n).ToArray();

            for (int v = 0; v < n; v++)
            {
                if (match[v] < 0)
                {
                    used = new bool[n];

                    if (Augument(v)) ret++;
                }
            }
            return ret;
        }

        private bool Augument(int v)
        {
            used[v] = true;

            foreach (var u in G[v])
            {
                int w = match[u];

                if (w < 0 || (!used[w] && Augument(w)))
                {
                    match[v] = u;
                    match[u] = v;
                    return true;
                }
            }
            return false;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int X = int.Parse(input[0]);
            int Y = int.Parse(input[1]);

            int V = X + Y;
            int E = int.Parse(input[2]);

            BipartiteMatching BM = new BipartiteMatching(V);

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int x = int.Parse(input[0]);
                int y = int.Parse(input[1]) + X;

                BM.AddEdge(x, y);
            }

            Console.WriteLine(BM.MaxmimumMatching());
        }
    }
}

Measured memory_bytes: 10460
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	int a[3]; REP(i,3){int tmp; cin >> tmp;  a[i] = tmp;}
	sort(a, a+3);
	cout << a[2]*10 + a[1] + a[0] << endl;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

int main()
{
	vector<int> a(3);
	int i;
	rep(i, 3) cin >> a[i];
	sort(ASC(a));
	cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 12 10:38:04 2019
D - Decayed Bridges
実行時間制限: 2 sec / メモリ制限: 1024 MB

配点 : 
400
 点
@author: justwah
"""

import sys
read = sys.stdin.readline

n, m = map(int, input().split())
score = n * (n-1) // 2

l = reversed([list(tuple(map(int, input().split()))) for i in range(m)])

parent = [i for i in range(n+1)]
rank = [0]*(n+1)
size = [1]*(n+1)

def root(x): #recursively find root for a node
    if parent[x] == x: # if at root, return self
        return x
    else:
        parent[x] = root(parent[x])  # while searching rejoint queried node to a common parent for hierarchical tree
        return parent[x]
    
def merge(a, b):
    a = root(a)
    b = root(b)
    if rank[a] < rank[b]: # joint lower rank node to a higher rank one
        parent[a] = b
    else:
        parent[b] = a
        if rank[a] == rank[b]: # rank only change if two same rank node joined
            rank[a] +=1
    size[a] += size[b]
    size[b] = size[a]
    return

ans = [score]
for a, b in l:
    a = root(a)
    b = root(b)
    if a != b:
        score -= size[a] * size[b]    
        merge(a, b)
        ans.append(score)
    else:
        ans.append(score)

print(*reversed(ans[:-1]))

Measured memory_bytes: 30916
#include <iostream>
#include <array>
using namespace std;
constexpr int FACE_NUM = 6;
class Dice {
 private:
  array<int, FACE_NUM> faces;

 public:
  explicit Dice(array<int, FACE_NUM> faces) : faces{faces} {}

  const int &getFace(int i) const {
    return faces[i];
  }

  void roll(char command) {
    switch (command) {
      case 'E':roll(3, 5, 2);
        break;
      case 'N':roll(1, 5, 4);
        break;
      case 'S':roll(4, 5, 1);
        break;
      case 'W':roll(2, 5, 3);
    }
  }

  void roll(int i, int j, int k) {
    int tmp = faces[0];
    faces[0] = faces[i];
    faces[i] = faces[j];
    faces[j] = faces[k];
    faces[k] = tmp;
  }
};

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

  array<int, FACE_NUM> faces;

  for (int i{0}; i < FACE_NUM; ++i) {
    cin >> faces[i];
  }
  Dice dice{faces};

  string commands;
  cin >> commands;
  for (int i{0}; i < commands.size(); ++i) {
    dice.roll(commands[i]);
  }

  cout << dice.getFace(0) << '\n';
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;


int main() {
    int x;
    cin >> x;
    int ans;
    rep(i,3000){
        if (x*(i+1)%360==0) {
            ans=i+1;
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636