akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <tuple>
#include <functional>
#include <map>
#include <unordered_map>
#include <queue>
#include <tuple>

using namespace std;

#define endl '\n'

using ull = unsigned long int;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);

  int n, k; cin >> n >> k;
  vector<ll> s(k+1), dp(k+1, 1e9 + 10);
  ++k;
  dp[1] = 0;
  cin >> s[1];
  for (int i = 2; i <= n; ++i) {
    cin >> s[i%k];
    dp[i%k] = dp[(i-1)%k] + abs(s[i%k] - s[(i-1)%k]);
    for (int l = 2; l < k and l < i; ++l) {
      dp[i%k] = min(dp[(i-l)%k] + abs(s[(i-l)%k] - s[i%k]), dp[i%k]);
    }
  }

  cout << dp[n%k] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  string A,B,C;
  cin>>A>>B>>C;
  cout<<char(char(A[0]) + 'A' - 'a');
  cout<<char(char(B[0]) + 'A' - 'a');
  cout<<char(char(C[0]) + 'A' - 'a');
  cout<<endl;
  return; 
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

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

bool sosu(int x){
 for(int i=2;i<x;i++){
   if(x%i ==0)return false;
 }
   return true;
}
int main() {
  int x;
  cin >>x;
  bool f= true;
  while(f){
   if(sosu(x)) f = false;
    else x++;
  }
  printf("%d\n",x);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int q, mas[10][10];
int draw[][5][5] = {
  /*Small*/
  {{ 0, 0, 1, 0, 0},
   { 0, 1, 1, 1, 0},
   { 0, 0, 1, 0, 0}},
  //*midium*/
  {{ 0, 0, 1, 1, 1},
   { 0, 0, 1, 1, 1},
   { 0, 0, 1, 1, 1}},
  /*large*/
  {{ 0, 0, 1, 0, 0},
   { 0, 1, 1, 1, 0},
   { 1, 1, 1, 1, 1},
   { 0, 1, 1, 1, 0},
   { 0, 0, 1, 0, 0}},
};
 
bool check( int y, int x, int w){
  for(int i = 0 ; i < 5 ; i++ ){
    for(int j = 0 ; j < 5 ; j++ ){
      if(mas[y + i][x + j - 2] - draw[w][i][j] < 0) return false;
    }
  }
  return true;
}
 
void paint( int y, int x, int w){
  for(int i = 0 ; i < 5 ; i++ ){
    for(int j = 0 ; j < 5 ; j++ ){
      mas[y + i][x + j - 2] -= draw[w][i][j];
    }
  }
}
 
void repaint( int y, int x, int w){
  for(int i = 0 ; i < 5 ; i++ ){
    for(int j = 0 ; j < 5 ; j++ ){
      mas[y + i][x + j - 2] += draw[w][i][j];
    }
  }
}
 
bool rec( int y, int x, int n){
  if( n < 0 ) return false;
  if( y == 10 ) return n == 0;
  if( mas[y][x] == 0 ) return rec( y + (x == 9), (x + 1) % 10, n);
  for(int i = 0 ; i < 3 ; i++ ){
    if(!check( y, x, i)) continue;
    paint( y, x, i);
    if(rec( y, x, n - 1)){
      cout << x + (i == 1) << " " << y + 1 + (i == 2) << " " << i + 1 << endl;
      return true;
    }
    repaint( y, x, i);
  }
  return false;
}
 
int main(){
  cin >> q;
  for(int i = 0 ; i < 10 ; i++ ){
    for(int j = 0 ; j < 10 ; j++ ){
      cin >> mas[i][j];
    }
  }
  rec( 0, 0, q);
 }

Measured memory_bytes: 3072
using System;
using CompLib.Util;

public class Program
{
    private int N;
    private int[] A;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.IntArray();

        //

        // i番目 選んだか? 選んだ - 選んでない + 2
        var dp = new long[N, 2, 5];
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < 2; j++)
            {
                for (int k = 0; k < 5; k++)
                {
                    dp[i, j, k] = long.MinValue;
                }
            }
        }

        for (int i = 0; i < N; i++)
        {
            if (i == 0)
            {
                dp[0, 1, 3] = A[0];
                dp[0, 0, 1] = 0;
                continue;
            }

            // A[i]を選ぶ
            for (int j = 1; j <= 4; j++)
            {
                if (dp[i - 1, 0, j - 1] == long.MinValue) continue;
                dp[i, 1, j] = Math.Max(dp[i, 1, j], dp[i - 1, 0, j - 1] + A[i]);
            }

            // 選ばない
            for (int j = 0; j < 4; j++)
            {
                if (dp[i - 1, 0, j + 1] != long.MinValue) dp[i, 0, j] = Math.Max(dp[i, 0, j], dp[i - 1, 0, j + 1]);
                if (dp[i - 1, 1, j + 1] != long.MinValue) dp[i, 0, j] = Math.Max(dp[i, 0, j], dp[i - 1, 1, j + 1]);
            }
        }

        long ans = N % 2 == 0
            ? Math.Max(dp[N - 1, 0, 2], dp[N - 1, 1, 2])
            : Math.Max(dp[N - 1, 0, 1], dp[N - 1, 1, 1]);

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 62596
package main

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

func nextChar(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int {
	i, _ := strconv.Atoi(nextChar(sc))
	return i
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		h := nextInt(sc)
		w := nextInt(sc)

		if h == 0 && w == 0 {
			return
		}

		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				fmt.Print("#")
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1092
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	var n, ans, min int
	fmt.Scan(&n)
	ans = -math.MaxInt64
	min = -ans
	for i := 0; i < n; i++ {
		var R int
		// fmt.Scanのループは遅い
		sc.Scan()
		R, _ = strconv.Atoi(sc.Text())
		if ans < R-min {
			ans = R - min
		}
		if min > R {
			min = R
		}
	}
	fmt.Println(ans)
}



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

int main(){
  string s, t; cin >> s >> t;
  int ssize = s.size(), tsize = t.size();
  if(ssize < tsize){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  bool ok;
  bool done = false;
  for(int i = ssize - tsize; i >= 0; i--){
    ok = true;
    for(int j = 0; j < tsize; j++){
      if(s.at(i+j) != '?' && s.at(i+j) != t.at(j)) ok = false;
    }
    if(ok){
      done = true;
      for(int k = i; k < i + tsize; k++){
        s.at(k) = t.at(k-i);
      }
      break;
    }
    if(ok) break;
  }
  if(!done) cout << "UNRESTORABLE" << endl;
  else{
    for(int i = 0; i < ssize; i++){
      if(s.at(i) == '?') s.at(i) = 'a';
    }
    cout << s << endl;
  }
}
  

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

bool check[6][6][6][6][6][6];

int index(string str){
	if(str == "Cyan"){
		return 0;
	}else if(str == "Yellow"){
		return 1;
	}else if(str == "Red"){
		return 2;
	}else if(str == "Magenta"){
		return 3;
	}else if(str == "Green"){
		return 4;
	}else{
		return 5;
	}
}

void rotate_1(int col[6]){
	int dummy = col[1];
	col[1] = col[2];
	col[2] = col[4];
	col[4] = col[3];
	col[3] = dummy;
}

void rotate_2(int col[6]){
	int dummy = col[3];
	col[3] = col[0];
	col[0] = col[2];
	col[2] = col[5];
	col[5] = dummy;
}

void rotate_3(int col[6]){
	int dummy = col[0];
	col[0] = col[1];
	col[1] = col[5];
	col[5] = col[4];
	col[4] = dummy;
}

void fill_rotate(int col[6]){
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			rotate_2(col);
			check[col[0]][col[1]][col[2]][col[3]][col[4]][col[5]] = true;
			for(int piyo = 0; piyo < 6; piyo++){
				//cout << col[piyo] << " ";
			}
			//cout << endl;
		}
		rotate_1(col);
	}
	rotate_3(col);
	for(int i = 0; i < 4; i++){
		rotate_2(col);
		check[col[0]][col[1]][col[2]][col[3]][col[4]][col[5]] = true;
			for(int piyo = 0; piyo < 6; piyo++){
				//cout << col[piyo] << " ";
			}
			//cout << endl;
	}
	rotate_3(col);
	rotate_3(col);
	for(int i = 0; i < 4; i++){
		rotate_2(col);
		check[col[0]][col[1]][col[2]][col[3]][col[4]][col[5]] = true;
			for(int piyo = 0; piyo < 6; piyo++){
				//cout << col[piyo] << " ";
			}
			//cout << endl;
	}
}

int main(){
	
	int n;
	
	while(true){
		
		cin >> n;
		
		if(n == 0){
			break;
		}
		
		int col[6];
		
		for(int i = 0; i < 6; i++){
		for(int j = 0; j < 6; j++){
		for(int k = 0; k < 6; k++){
		for(int l = 0; l < 6; l++){
		for(int m = 0; m < 6; m++){
		for(int n = 0; n < 6; n++){
			check[i][j][k][l][m][n] = false;
		}}}}}}
		
		int ans = 0;
		
		for(int loop = 0; loop < n; loop++){
			for(int i = 0; i < 6; i++){
				string str;
				cin >> str;
				col[i] = index(str);
			}
			
			if(!check[col[0]][col[1]][col[2]][col[3]][col[4]][col[5]]){
				ans++;
				fill_rotate(col);
			}
		}
		
		cout << n - ans << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 3180
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cctype>
using namespace std;
char tmp;
int read()
{
    int f(1),x(0);
    for(tmp=getchar();!isdigit(tmp);tmp=getchar()) if(tmp=='-') f=-1;
    for(;isdigit(tmp);tmp=getchar()) x=x*10+tmp-'0';
    return f*x;
}
typedef struct interval{
    int left,right;
    bool operator<(const struct interval & b)const
    {
        return this->right<b.right;
    }
}ITV;
ITV intervals[100000];
int last=-1,n,m,ans;
int main()
{
    n=read(); m=read();
    for(int i=0;i<m;i++)
        intervals[i].left=read(),intervals[i].right=read()-1;
    sort(intervals,intervals+m);
    for(int i=0;i<m;i++)
    {
        if(last>=intervals[i].left&&last<=intervals[i].right)
            continue;
        last=intervals[i].right;
        ans++;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

/**
 * @author yamamotoa
 *
 */
public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int ans;
		int num;
		while(sc.hasNext()) {
			num = sc.nextInt();
			ans = 0;

			for(int a = 0; a < 10; a++) {
				for(int b = 0; b < 10; b++) {
					for(int c = 0; c < 10; c++) {
						for(int d = 0; d < 10; d++) {
							if(a + b + c + d == num) {
								ans++;
							}
						}
					}
				}
			}
			System.out.println(ans);
		}

	}

}

Measured memory_bytes: 26420
#include<stdio.h>
int main(){
	long long a,b,n;
	while(scanf("%lld%lld%lld",&n,&a,&b)!=EOF){
		if(a>b)
			printf("0\n");
		else if(n==1){
			if(a==b)
				printf("1\n");
			else
				printf("0\n");
		}
		else{
			long long sum=(n-2)*((b-a));
			printf("%lld\n",sum+1);
		}
	}
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int N,M;
   cin>>N>>M;
   vector<int>A(N);
   vector<int>B(N);

   int64_t ans=0;
   for(int i=0;i<N;i++){
      cin>>A[i]>>B[i];
   }
   vector<pair<int,int>>AB(N);
   for(int i=0;i<N;i++){
      AB[i]=make_pair(A[i],B[i]);
   }
   sort(AB.begin(),AB.end());
   for(int i=0;i<N;i++){
    //  if(c[A[i]]>=M){ans+=A[i]*M;break;}
     // else{ans+=A[i]*c[A[i]];M-=c[A[i]];}
     int64_t buy=min(M,AB[i].second);
     ans+=buy*AB[i].first;
     M-=buy;
   }
   cout<<ans<<endl;
return 0;}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 998244353;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 1003455

int v[tam];
int f(int y,int x,int yy,int xx)
{
    return (abs(y-yy)+abs(x-xx))%2==1;
}
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    forr(i,1,n+1)
    cin>>v[i];
    sort(v+1,v+n+1);
    reverse(v+1,v+n+1);
    int x,y;
    x=y=1;
    forr(i,1,n+1)
    {
        if (y>v[i])break;
        y++;x++;
    }
    y--,x--;
    bool win=0;
    if (x<n)
    {
        int lst=0;
        forr(i,1,n+1)
        {
            if (y==v[i])
                lst=i;
        }
        if (lst!=0)
        win=f(y,x,v[lst],lst);
        if (v[x]!=y)
            win|=f(y,x,y,v[x]);

    }
    else
    {
        win=f(y,x,v[n],n);
    }
    if (win)
        cout<<"First\n";
    else
        cout<<"Second\n";
}
// PLUS ULTRA!!

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

ll gcd(ll a,ll b)
{
	return b? gcd(b,a%b):a;
}

ll pow(ll a, ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

int ugabuga()
{

	ll n,k;
	cin>>n>>k;
	vector<ll>a(n),b(n);

	for(int i=0;i<n;i++) cin>>a[i]>>b[i];

	ll sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=b[i];
	}

	vector<ll>dp(sum+1,1e18L);
	dp[0]=0;

	ll ans=0;
	for(int i=0;i<n;i++)
	{
		for(int j=sum-b[i];j>=0;j--)
		{
			dp[j+b[i]]=min(dp[j+b[i]],dp[j]+a[i]);
		}
	}

	for(int i=0;i<=sum;i++)
	{
		if(dp[i]<=k) ans=i;
	}

	cout<<ans;

	return 0;
}


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

    int t=1;
    //cin>>t;
    while(t--)
    {
        ugabuga();
    }

}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

int n, k;

bool f(int ma){
    rep(i,n-1){
        ma--;
        if(ma <= 0)return true;
        int t = ma/k;
        ma -= t;
    }
    return ma <= 0;
}

signed main(void) {
    cin >> n >> k;
    int lb = n-1, ub = (ll)INF*INF;
    while(lb+1 < ub){
        int mid = (lb + ub)/2;
        if(f(mid)) lb = mid;
        else ub = mid;
    }
    cout << lb << endl;
}



Measured memory_bytes: 3124
# -*- coding: utf-8 -*-

import sys
import math

def main():
    input = sys.stdin.readline
    a, b, h, m = map(int, input().split())
    h_angle = h * 30 + m * 0.5
    m_angle = m * 6
    radian = 0
    if h_angle > m_angle:
        angle = h_angle - m_angle
    else:
        angle = m_angle - h_angle
    if angle > 180:
        angle = 360 - angle
    radian = math.radians(angle)
    c_2 = (a**2 + b**2) - (2 * a * b * math.cos(radian))
    print('{:.20f}'.format(math.sqrt(c_2)))
    return 


if __name__ == '__main__':
    main()

Measured memory_bytes: 9440
import Control.Applicative
import Data.List
import qualified Data.Set as Set
import qualified Data.IntMap as IMap

main = do
    [n,k] <- map read . words <$> getLine  :: IO [Int]
    list <- sequence (replicate n ((\[x,y]->(x,y)) . map read . words <$> getLine)) :: IO [(Int,Int)]
    print $ solve k list

solve :: Int -> [(Int,Int)] -> Int
solve k list = fd k dic
    where dic = make list

fd k dic = if b >= k then a else (fd (k-b) dic_)
    where ((a,b),dic_) = IMap.deleteFindMin dic

make :: [(Int,Int)] -> IMap.IntMap Int
make list = foldl append IMap.empty list

append :: IMap.IntMap Int -> (Int,Int) -> IMap.IntMap Int
append dic (a,b) = case mb of Nothing -> IMap.insert a b dic
                              Just x  -> IMap.update (\y -> Just (b+y)) a dic
    where mb = IMap.lookup a dic



Measured memory_bytes: 97660
import java.util.Scanner;
import java.util.Arrays;

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

        weather[0] = "Sunny";
        weather[1] = "Cloudy";
        weather[2] = "Rainy";

        for (int i=0; i <= weather.length; i++) {
            if (weather[i].equals(s)) {
                System.out.println(i >= 2 ? weather[0] : weather[i+1]);
                break;
            }
        }
    }
}

Measured memory_bytes: 20564
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

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

signed main(void) {
    int n,x;
    cin >> n >> x;
    vi a(n);
    rep(i,n)cin >> a[i];
    sort(all(a));
    vvi dp(n+1,vi(x+1,0));
    rep(i,x+1)dp[0][i] = i;
    rep(i,n)rep(j,x+1){
        dp[i+1][j] += dp[i][j]*i + dp[i][j%a[i]];
        dp[i+1][j] %= MOD;
    }
    cout << dp[n][x] << endl;
}


Measured memory_bytes: 158720
#include <bits/stdc++.h>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) ((a)>(0)?(a):-(a))
#define rep(i,l,r) for((i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    int n,i,buf1,h;
    cin>>n;
    cin>>buf1;
    rep(i,1,n){
        cin>>h;
        if(buf1<h)h--;
        else if(buf1>h){
            cout<<"No"<<endl;
            return 0;
        }
        buf1=h;
    }
   cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
th = input()
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print (nums[int(th)-1])


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

using namespace std;
using ll = long long;
using ull = unsigned long long;

const int MOD = 1000000007;

ll dp[2010][2010];

ll f1(ll in, ll i, ll n, vector<pair<ll, ll>> &a) {
    if (in == a.size())
        return 0;

    if (dp[in][i] != -1)
        return dp[in][i];
    int end = n - 1 - (in - i);

    ll ans1 = (a[in].first * (a[in].second - i)) + f1(in + 1, i + 1, n, a);
    ll ans2 = (a[in].first * (end - a[in].second)) + f1(in + 1, i, n, a);

    return dp[in][i] = max(ans1, ans2);
}
void solve() {
    ll n;
    cin >> n;
    vector<pair<ll, ll>> a;

    for (ll i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        a.push_back(make_pair(x, i));
    }

    memset(dp, -1, sizeof(dp));
    sort(a.rbegin(), a.rend());

    ll ans = f1(0, 0, n, a);
    cout << ans << "\n";
}

int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin >> t;

    // while (t--)
    solve();

    return 0;
}


Measured memory_bytes: 35432
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N;
	cin >> N;
	while (N--) {
		int field[9][9];
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				cin >> field[i][j];
			}
		}
		vector<vector<int>>oks(9, vector<int>(9,true));
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				for (int k = 0; k < 9; ++k) {
					if (j == k)continue;
					if (field[i][j] == field[i][k])oks[i][j] = false;
				}
				for (int k = 0; k < 9; ++k) {
					if (i == k)continue;
					if (field[i][j] == field[k][j])oks[i][j] = false;
				}
				int ax = j / 3;
				int ay = i / 3;
				for (int k = ax * 3; k < ax * 3 + 3; ++k) {
					for (int l = ay * 3; l < ay * 3 + 3; ++l) {
						if (k == j&&l == i)continue;
						if (field[i][j] == field[l][k])oks[i][j] = false;
					}
				}
			}
		}
		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				if (oks[i][j])cout << " ";
				else cout << "*";
				cout << field[i][j];
			}
			cout << endl;
		}
		if(N)cout << endl;
		
	}
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
double distance(int a,int b,int c,int d){ return sqrt((a-c)*(a-c)+(b-d)*(b-d)); }
int main() {
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  rep(i, M){
    cin >> B[i];
  }
  int tmp;
  int now;
  int ans = 0;
  rep(i, N) {
    now = 0;
    rep(j, M) {
      cin >> tmp;
      now += tmp*B[j];
    }
    now += C;
    //dout << now << endl;
    if (now > 0) {
      ans++;
    }
  }
  cout << ans;
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

*/


Measured memory_bytes: 256
fun main(arg: Array<String>) {
    val N = nextInt()
    val AA = listOfLong()
    val A = AA.toMutableList()
    A.add(0, 0)
    val dp = Array(N + 1) { LongArray(2) }
    dp[2][1] = A[2]
    dp[2][0] = A[1]
    for (i in 3 .. N) {
        if (i and 1 == 1) {
            val temp = listOf(dp[i - 3][1], dp[i - 3][0], dp[i - 2][1], dp[i - 2][0]).max()!!
            dp[i][1] = A[i] + temp
            dp[i][0] = listOf(dp[i - 1][1], dp[i - 1][0], A[i - 2] + dp[i - 3][0]).max()!!
        } else {
            dp[i][1] = A[i] + listOf(dp[i - 2][1], dp[i - 2][0], dp[i - 1][0]).max()!!
            dp[i][0] = A[i - 1] + dp[i - 2][0]
        }
    }
    val ans = Math.max(dp[N][0], dp[N][1])
    println(ans)
}

fun next() = readLine()!!
fun nextInt(offset: Int = 0) = Integer.parseInt(next()) + offset
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfDouble() = listOfString().map(String::toDouble)
fun listOfInt(offset: Int = 0) = listOfString().map { Integer.parseInt(it) + offset }
fun listOfInt(vararg offset: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + offset[index % offset.size] }
fun listOfLong(offset: Long = 0L) = listOfString().map { java.lang.Long.parseLong(it) + offset }
fun listOfLong(vararg offset: Long) = listOfString().map { java.lang.Long.parseLong(it) }.mapIndexed { index, long -> long + offset[index % offset.size] }
fun listOfDouble(offset: Double = 0.0) = listOfString().map { java.lang.Double.parseDouble(it) + offset }
fun pairIntLong() = listOfLong().let { Pair(it[0].toInt(), it[1]) }
fun tripleIntIntLong() = listOfLong().let { Triple(it[0].toInt(), it[1].toInt(), it[2]) }
fun tripleIntLongLong() = listOfLong().let { Triple(it[0].toInt(), it[1], it[2]) }
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }
fun tripleIntIntLong(offset: Triple<Int, Int, Long> = Triple(0, 0, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1].toInt() + offset.second, it[2] + offset.third) }
fun tripleIntLongLong(offset: Triple<Int, Long, Long> = Triple(0, 0L, 0L)) = listOfLong().let { Triple(it[0].toInt() + offset.first, it[1] + offset.second, it[2] + offset.third) }



Measured memory_bytes: 83364
N, M = map(int, input().split())
X = sorted(list(map(int, input().split())))

D = []
for i in range(1, M):
    d = X[i] - X[i - 1]
    D.append(d)
D.sort()

if N != 1:
    D = D[:-1 * (N - 1)]

print(sum(D))


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

int main(){
  constexpr int Ncolor= 8;
  int N;
  cin >> N;

  unordered_map<int, int> freq_fixed;
  int Nchameleon= 0;

  int rate;
  for(int i=0; i<N; i++){
    cin >> rate;
    int tier= rate/400;

    if(tier < Ncolor){
      if(freq_fixed.count(tier)){ freq_fixed.at(tier)++; }
      else                      { freq_fixed[tier]= 1; }
    }
    else{
      Nchameleon++;
    }
  }

  int Nfixed= freq_fixed.size();
  int ans_min= max(Nfixed, 1);
  int ans_max= Nfixed+ Nchameleon; // デフォルトの色以外も選べる

  cout << ans_min <<" "<< ans_max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,f=0;
    // 整数の入力
    // スペース区切りの整数の入力
    scanf("%d %d %d",&a,&b,&c);
    // 出力
  for(int i=1;i<=200;i++){
    if((a*i-c)%b==0){
      printf("YES");
      f=1;
      break;
    }
  }
    if(f==0)printf("NO");
    return 0;
}

Measured memory_bytes: 128
import sys
import numpy as np
from heapq import heappop, heappush

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def choose_increasing(q):
    A = []
    for x in q:
        while A and A[-1] >= x:
            A.pop()
        A.append(x)
    return np.array(A, np.int64)

def main(A, N):
    heap = [(-A[-1], 1)]
    for n in A[::-1]:
        while True:
            if -heap[0][0] <= n:
                break
            x, coef = heappop(heap)
            while heap and heap[0][0] == x:
                _, c = heappop(heap)
                coef += c
            q, r = divmod(-x, n)
            heappush(heap, (-n, coef * q))
            heappush(heap, (-r, coef))
    ret = np.zeros(N + 10, np.int64)
    for x, c in heap:
        x = -x
        ret[1] += c
        ret[x + 1] -= c
    ret = np.cumsum(ret)
    return ret[1:N + 1]

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8[:], i8))
    cc.compile()

from my_module import main

N, Q = map(int, readline().split())
q = [N] + list(map(int, read().split()))

A = choose_increasing(q)
ans = main(A, N)
print('\n'.join(map(str, ans.tolist())))

Measured memory_bytes: 44068
#include <stdio.h>
int main(){
  int n, a;
  scanf("%d",&n);
  int max=0, sum=0;
  for(int i=0;i<n;i++){
    a = 0;
    scanf("%d", &a);
    if(a>max){
      max=a;
      sum+=a;
    }
    else{
      sum+=a;
    }
  }
  
  sum-=max;
  if(max<sum){
    printf("Yes");
  }
  else{
    printf("No");
  }
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef short int si;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

#define st first
#define nd second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REV(a) reverse(a.begin(),a.end())
#define SORT(a) sort(a.begin(),a.end())
#define inf (int)1e9
#define linf (ll)1e18

int n,c;
vpii q;
pair<pii,int >t[100000];
int fc;

bool cmp(pii a,pii b){
		return a.first+(a.second==fc?0:1)<b.first+(b.second==fc?0:1);
}

int main() {
		ios::sync_with_stdio(false);
		cin>>n>>c;
		FOR(i,0,n){
				cin>>t[i].first.first>>t[i].first.second>>t[i].second;
		}
		sort(t,t+n);
		q.push_back({-1,0});
		FOR(i,0,n){
				fc=t[i].second;
				sort(q.begin(),q.end(),cmp);
				if(q[0].first+(q[0].second==fc?0:1)<=t[i].first.first){
						q[0].first=t[i].first.second;
						q[0].second=t[i].second;
				}
				else {
						q.push_back({t[i].first.second,fc});
				}
		}
		cout<<q.size()<<endl;



		return 0;
}




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

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =
				new BufferedReader(new InputStreamReader(System.in));
		for (String str; (str = br.readLine()) != null; /* */) {
			String[] data = str.split(",");
			int[] l = new int[11];
			l[0] = 0;
			for (int i = 1; i <= 10; i++) {
				l[i] = l[i-1] + Integer.parseInt(data[i-1]);
			}
			int v1 = Integer.parseInt(data[10]);
			int v2 = Integer.parseInt(data[11]);

			int p = l[10]*v1 / (v1+v2);
			for (int i=0; i <= 9; i++) {
				if (p == l[i]) {
					if (l[10]*v1 % (v1+v2) == 0) {
						System.out.println(i);
						break;
					} else {
						System.out.println(i+1);
						break;
					}
				} else if (l[i] < p && p < l[i+1]) {
					System.out.println(i+1);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 24160
#include <algorithm>
#include <cstring>
#include <iostream>
#include <cstdio>
using namespace std;
const int N=1e5+10;
int a[N],b[N];
const int MOD=1e9+7;
int main()
{
    int n;
    scanf("%d",&n);
    a[0]=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    b[n+1]=0;
    for(int i=1;i<=n;i++) scanf("%d",&b[i]);
    int ma,mb,f1,f2;
    long long ans=1;
    for(int i=1;i<=n;i++)
    {
        f1=f2=0;
        ma=a[i];mb=b[i];
        if(a[i-1]!=a[i]) f1=1;
        if(b[i+1]!=b[i]) f2=1;
        if(f1) if(mb<ma) {ans=0;break;}
        if(f2) if(ma<mb) {ans=0;break;}
        if(!f1&&!f2) ans=(ans*min(ma,mb))%MOD;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int X, Y;
	cin >> X >> Y;
	REP(i, X + 1) {
		int j = X - i;
		if (i * 2 + j * 4 == Y) {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";

	return 0;
}


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

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

	int n;
	cin >> n;

	long long ryu[87];
	ryu[0] = 2;
	ryu[1] = 1;
	for(int i = 2; i < 87; i++){
		ryu[i] = ryu[i-1] + ryu[i-2];
	}
	cout << ryu[n] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <cstdint>
#include <numeric>
#define INF 1000000000
#define LLINF 2000000000000000
#define MOD 1000000007
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
#define int long long

signed main(){
  int n,k;
  cin >> n >> k;
  int a[n+1];
  LOOP1(i,n){
    cin >> a[i];
  }

  int cnt[200001] = {};
  int np = 1;
  int t = 1;
  while(cnt[np]==0){
    cnt[np] = t;
    // cerr << np << " ";

    np = a[np];
    if(k==t){
      // cerr << "ans:";
      cout << np << endl;
      return 0;
    }
    t++;
  }
  k+=1;
  int diff = t - cnt[np];
  k = (k - cnt[np]) % diff;
  int i = 0;
  while(1){
    if(i==k){
      cout << np << endl;
      return 0;
    }
    np = a[np];
    i++;
  }
}


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

long long sum[200020];

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

	sum[0] = 0;
	for (int i = 1; i<= N; i++) {
		int a;
		cin >> a;
		sum[i] = sum[i-1]+a;
	}
	long long min_diff = abs(sum[N] - sum[1] - sum[1]);
	for (int i = 2; i < N; i++) {
		min_diff = std::min(min_diff, abs((sum[N]-sum[i]-sum[i])));
	}
	cout << min_diff << endl;

	return 0;
}


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

/*
 3*673

[2019]n はng
*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string Sc;
	cin >> Sc;

	int N = Sc.size();

	// cout << N;

	vector<int> modlist(2019, 0);
	vector<int> old_modlist(2019, 0);
	long long result = 0;
	for (int i = 0; i < N; i++) {
		int s = Sc[i] - '0';
		modlist[s]++;
		for (int j = 0; j < 2019; j++) {
			int j_mod = (j * 10 + s) % 2019;
			// cout << old_modlist[j] << ":" << j << "+" << s << "=" << j_mod
			//  << "\n";
			if (j_mod == 0) {
				result += old_modlist[j];
			}
			modlist[j_mod] += old_modlist[j];
		}
		for (int j = 0; j < 2019; j++) {
			old_modlist[j] = modlist[j];
			modlist[j] = 0;
		}
	}
	cout << result;
	return 0;
}

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

using namespace std;
#define int long long
int calc[27];
#undef int
int main(){
	#define int long long
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int ans=0;
	string t;cin>>t;
	ans=1+(t.size()*(t.size()-1))/2;
	for(int i=0;i<t.size();i++){
		calc[t[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		ans-=(calc[i]*(calc[i]-1))/2;
	}
	cout<<ans<<endl;
	return 0;
}

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

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

int main(){
    long int A,B,C,D;
    cin>>A>>B>>C>>D;
    long int X=B/C-(A-1)/C;
    long int Y=B/D-(A-1)/D;
    long int Z=B/lcd(C,D)-(A-1)/lcd(C,D);
    cout<<B-A+1-(X+Y-Z)<<endl;
}

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

int main(void)
{
    int A, B;
    cin >> A >> B;

    if (A <= 8 && B <= 8)
    {
        cout << "Yay!" << endl;
    }
    else
    {
        cout << ":(" << endl;
    }
    return (0);
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

# A B -> A
# AB -> B
# AB -> B
# B A -> A
# A  B -> B
# A B  -> A
# A B -> A
#  AB -> B
# A   B -> A
# A  B -> B
# A  B  ->

diff = b - a
if diff % 2 == 0:
    print("Alice")
else:
    print("Borys")


Measured memory_bytes: 38384
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int num_10,num_100;
};

int main(){

	int N,T,H,Limit;
	scanf("%d %d %d %d",&N,&T,&H,&Limit);

	int store_10 = T,store_100 = H;
	int zankin;

	Info info[N];

	for(int i = 0; i < N; i++){
		scanf("%d %d",&info[i].num_10,&info[i].num_100);
	}

	zankin = 0;
	int otsuri;

	while(true){

		for(int i = 0; i < N; i++){
			if(info[i].num_10 > 0){
				info[i].num_10 -= 1;
				zankin += 10;
				store_10++;

				if(store_10 > Limit){
					printf("%d\n",i+1);
					return 0;
				}

				if(zankin == 90)zankin = 0;

			}else if(info[i].num_100 > 0){
				info[i].num_100 -= 1;
				zankin += 100;
				store_100++;

				otsuri = zankin - 90;
				zankin = 0;

				while(store_10 > 0 && otsuri > 0){
					store_10--;
					info[i].num_10++;
					otsuri -= 10;
				}

				if(otsuri > 0){
					printf("%d\n",i+1);
					return 0;
				}

			}else{
				printf("%d\n",i+1);
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3176
use proconio::{input, marker::Bytes};

fn main() {
    input!(s: Bytes);
    let mut ans = 0;
    let mut cur = 0;
    for c in s {
        if c == b'R' {
            cur += 1;
        } else {
            cur = 0;
        }
        ans = ans.max(cur);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> P(N), Q(N);
    for (auto &p : P) cin >> p;
    for (auto &q : Q) cin >> q;
    if (P > Q) swap(P, Q);
    int ans = 0;
    do {
        if (P == Q) break;
        ans++;
    } while (next_permutation(begin(P), end(P)));
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    int a[10];
    for (int i = 0; i < 10; i++) {
        cin >> a[i];
    }
    sort(a, a + 10);
    for (int i = 9; i >= 7; i--) {
        cout << a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            string n = Console.ReadLine();
            string s = Console.ReadLine(); 

            if (s.Length % 2 == 1)
            {
                Console.WriteLine("No");
                return;
            }

            string h = s.Substring(0, (s.Length / 2));

            if ((h + h) == s)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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

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

  int n;
  cin >> n;
  int l, r;
  int tot = 0;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    tot += r - l + 1;
  }
  cout << tot << '\n';
  return 0;
}

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

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列配列の入力
            string[] inputStrArray = Console.ReadLine().Split(' ');

            var x = (int)inputStrArray[0][0];
            var y = (int)inputStrArray[1][0];

            if (x < y) {
                Console.WriteLine("<");
            } else if (y < x) {
                Console.WriteLine(">");
            } else {
                Console.WriteLine("=");
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 11092
package main

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

type square struct {
	h int64
	w int64
}

func main() {
	const frame = "#"
	const inside = "."

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	var in []*square
	for {
		s := &square{
			nextInt(sc),
			nextInt(sc),
		}

		if s.h == 0 && s.w == 0 {
			break
		}
		in = append(in, s)
	}

	var results []string
	for _, s := range in {
		line := strings.Repeat(frame, int(s.w)) + "\n"
		inLine := frame + strings.Repeat(inside, int(s.w)-2) + frame + "\n"
		set := line + strings.Repeat(inLine, int(s.h)-2) + line
		results = append(results, set)
	}

	fmt.Println(strings.Join(results, "\n"))
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func nextInt(sc *bufio.Scanner) int64 {
	i, err := strconv.ParseInt(nextString(sc), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}



Measured memory_bytes: 1472
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n - 1; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
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;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<ll> a(N), b(N);
    REP(i, N) cin >> a[i] >> b[i];
    map<pair<ll, ll>, int> m;

    REP(x, N) {
        REP(nx, N) {
            if (x == nx)
                continue;
            ll p = a[x] - a[nx];
            ll q = b[x] - b[nx];
            if (m.count({p, q})) {
                m[{p, q}]++;
            } else {
                m[{p, q}] = 1;
            }
        }
    }
    ll P, Q;
    int cnt = 0;
    for (auto &&i : m) {
        if (chmax(cnt, i.second)) {
            P = i.first.first;
            Q = i.first.second;
        }
    }
    vector<bool> f(N, true);
    int ans = N - cnt;
    // REP(i, N) {
    //     REP(j, N) {
    //         if (i == j)
    //             continue;
    //         ll x = a[i] - P;
    //         ll y = b[i] - Q;
    //         if (x == a[j] && y == b[j] && f[i] && f[j]) {
    //             f[i] = false;
    //             ans--;
    //         }
    //     }
    // }
    print(ans);

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
using namespace std;

int main(){
    int r,g,b;
    cin >> r >> g >> b;

    int sum=r*100+10*g+b;

    if(sum%4==0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	
	if(s.size()%2 == 1){
		cout << "No" << endl;
		return 0;
	}
	
	vector<char> t;
	
	rep(i,s.size()/2){
		t.push_back(s[i]);
	}
	
	rep(i,s.size()/2){
		if(t[i] != s[s.size()/2 + i]){
			cout << "No" << endl;
			return 0;
		}
	}
	
	
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256