akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

using namespace std;

int sum(int n){
int res = 1;
while(n / 10 != 0){
res++;
n/=10;
}

return res;
}

int main()
{
int a,b;
while(~scanf("%d %d",&a,&b)){
printf("%d\n",sum(a+b));
}

return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

ll calc(ll num,ll x){
    ll sum=0;
    while(num){
        sum+=num%x;
        num/=x;
    }
    return sum;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,S;
    cin>>N>>S;
    if(N==S){
        cout1(N+1);
        return 0;
    }
    
    for(ll x=2;x*x<=N;x++)if(S==calc(N,x)){
        cout1(x);
        return 0;
    }
    
    ll ans=LLINF;
    for(ll p=1;p*p<N&&p<=S&&p<ans;p++){
        ll q=S-p;
        if((N-q)>=0&&(N-q)%p==0){
            ll b=(N-q)/p;
            if(b>p&&b>q&&ans>b) ans=b;
        }
    }
    
    if(ans==LLINF) ans=-1;
    cout1(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
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; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
  int n,m;
  cin >> n >> m;
  cout << (n-1)*(m-1) << "\n";
}


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

using namespace std;

int main(){
	string s;
	int q;
	
	cin >> s;
	cin >> q;
	
	for(int i=0; i<q; ++i){
		string od, p;
		int a, b;
		
		cin >> od >> a >> b;
		if(od=="replace"){
			cin >> p;
			s = s.replace(a, b-a+1, p);
		}
		else if(od=="print"){
			cout << s.substr(a, b-a+1) << endl;
		}
		else if(od=="reverse"){
			string tmp = s.substr(a, b-a+1);
			reverse(tmp.begin(), tmp.end());
			//cout <<"tmp=" << tmp <<endl;
			s = s.replace(a, b-a+1, tmp);	
		}
		
		//cout << s << endl;
		
	}
	return 0;
}



Measured memory_bytes: 3216
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
def abs(k,l):
  if k>l:
    return k-l
  else:
    return l-k  
b=20000313
cnt=0
for i in range(n):
  if b>abs(a,t-0.006*h[i]):
    b=abs(a,t-0.006*h[i])
    cnt=i
  else:
    b=b
    cnt=cnt
print(cnt+1)

  
  
  


Measured memory_bytes: 3060
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}
use input::*;

fn main() {
    let (n, m): (usize, usize);
    input!(n, m);
    p((n - 1) * (m - 1));
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;


int main(){
    int n,k;
    cin >> n >> k;
    vector<bool>sunuke(n,true);
    rep(i,k){
        int d;
        cin >> d;
        rep(j,d){
            int a;
            cin >> a;
            a--;
            sunuke[a]=false;
        }
    }
    int ans = 0;
    rep(i,n){
        if(sunuke[i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
int main() {
    ll n;
    std::cin >> n;
    vector<ll> d(n);
    for (int i = 0; i < n; i++) {
        std::cin >> d[i];
    }
    ll res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            res += d[i]*d[j];
        }
    }
    std::cout << res << std::endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split(" "))
a = [input() for i in range(n)]
b = [input() for i in range(m)]

for y in range(n-m+1):
    for x in range(n-m+1):
        if [line[x:x+m] for line in a[y:y+m]] == b:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
n=int(input())
w=list(map(int,input().split()))
s=[0]
for i in w:
    s.append(s[-1]+i)
ss=s[-1]
ans=10**20
for i in range(n+1):
    ans=min(ans,abs((ss-s[i])-s[i]))
print(ans)

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

int main(){
  int h, w;
  cin >> h >> w;
  string pix[h];
  for(int i = 0; i < h; i++){
    cin >> pix[i];
  }
  for(int i = 0; i < h; i++){
    cout << pix[i] << endl;
    cout << pix[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int p, q, r;
	int i, j, k;
	int sum = 0;
	int min = 0;
	int count;
	int grid_w[2000][2000] = {{0}};
	int grid_h[2000][2000] = {{0}};
	char str[2000][2001];
	
	scanf("%d%d%d", &p, &q, &r);
	
	sum = p + q + r;
	
	if(min < p) {
		min = p;
	}
	
	if(min < q) {
		min = q;
	}
	
	if(min < r) {
		min = r;
	}
	
	printf("%d\n", sum - min);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
char s[3];
cin>>s;
  int count=0;
  int max=0;
for(int i=0;i<3;i++)
{if(i==2&&s[i]=='R')
{count++;
 max=count;
break;}
 else if(s[i]=='R')
{count++;}
 else{
   if(max<count)
   {max=count;}
   count=0;}
}
  cout<<max;

}


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

int main(void){
    int n;
    double x[2], y[2], r[2];
    cin >> n;
    rep(data, n) {
        rep(i, 2) cin >> x[i] >> y[i] >> r[i];
        double dist = sqrt(pow(y[1]-y[0], 2.0) + pow(x[1]-x[0], 2.0));

        if(r[0] > r[1] && dist < r[0]-r[1]) cout << 2 << endl;
        else if(r[1] > r[0] && dist < r[1]-r[0]) cout << -2 << endl;
        else if(dist > r[0] + r[1]) cout << 0 << endl;
        else cout << 1 << endl;
    }
}

Measured memory_bytes: 1232
#include <cstdio>
#define ll long long int
#define MOD 1000000007
ll N, A[200005], sum[200005], ans;
ll SUM(int i, int j)
{
	return (sum[j]-sum[i-1])%MOD;    //此时 sum[j]-sum[i-1] 是正数 
}
int main()
{
	scanf("%lld", &N);
	for(int i=1;i<=N;i++)
	{
		scanf("%lld", &A[i]);
		sum[i] = sum[i-1]+A[i];     //sum 不取模 
	}
	for(int i=1;i<N;i++)
		ans = (ans+(A[i]*SUM(i+1, N))%MOD)%MOD;
	printf("%lld\n", ans);
	return 0;
}

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


int main() {
	int N;
	cin >> N;
	vector<ll> v(N + 1);
	if (N == 0){
		cout << 2 << endl;
		return 0;
	}
	if (N == 1){
		cout << 1 << endl;
		return 0;
	}
	v[0] = 2LL;
	v[1] = 1LL;
	for (int i = 2; i <= N; i++){
		v[i] = v[i - 1] + v[i - 2];
	}
	cout << v[N] << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main(){

	int n,m;
	int dist[100001];
	//while(scanf("%d %d\n",&n,&m)&&!(n==0&&m==0)){
	{
		scanf("%d %d\n",&n,&m);
		memset(dist,0,sizeof(dist));
		int sumDist=0;
		for(int i = 1; i <= n; i++){
			dist[i]=sumDist;
			if(i==n)
				break;
			int t;
			scanf("%d",&t);
			//cin>>t;
			sumDist+=t;
		}
		int cp=1;
		int movingDistance=0;
		for(int i = 0; i < m; i++){
			int dd;
			//cin>>dd;
			scanf("%d",&dd);
			cp+=dd;
			movingDistance+=abs(dist[cp]-dist[cp-dd]);
			movingDistance%=100000;
		}
		//cout<<movingDistance%100000<<endl;
		printf("%d\n",movingDistance%100000);
	}

	return 0;
}

Measured memory_bytes: 1224
#include<stdio.h>
int main(void){
  char ramen[3];
  int ryokin=700;
  scanf("%s", ramen);
  for(int i=0; i < 3; i++){
    if(ramen[i] == 'o'){
      ryokin+=100;
    }
  }
  printf("%d\n", ryokin);
  return 0;
}

Measured memory_bytes: 128
/*
 author : nit1n
 created : 13/09/2020 18:04:37
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int mod =1e9 + 7 ;
int power(int a , int b)
{
	int ans =1 ; 
	while(b)
	{
		if(b &1)
		{
			ans *=a ; 
			ans %= mod; 
		}
		a *= a ; 
		a %= mod ;
		b >>=1 ;
	}
	return  ans ; 
}

int modinv(int a )
{
	return power(a , mod -2 ) ; 
}

int comb(int a , int b )
{
	int ans =1 ; 
	for(int i = a; i > a- b  ; --i)
	{
		  ; 
		ans *= (i *modinv(a - i + 1 ))%mod ; 
	//	cout<< "i " << i << " " << ans << endl ;
		ans %= mod ; 
	}
	return ans ; 
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n ; 
	cin >> n ;
	int k = n/3 ; 
	int x = 1 ;
	int ans  =1  ; 
	if(n < 3 )
		cout << 0 ; 
	else 
	{
		for(int i = 0; i < k-1 ; ++i)
		{
			int s  = n- (x+1)*3 ;
			int te = comb(s + x, x ) ; 
			ans += te; 
			ans %= mod ;  
			x++ ; 
		//	cout << te << endl ;
		}
		cout << ans  ;
	}
}



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

int main(void)
{
	int a[3];

	cin >> a[0] >> a[1] >> a[2];

	sort(a, a+3);

	for (int i = 0; i < 3; i++)
	{
		if (i < 2)
		{
			cout << a[i] << " ";
		}
		else
		{
			cout << a[i] << endl;
		}
	}

	return 0;
}

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

namespace ABC136A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c, d;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            d = b + c;
            if (d <= a)
                Console.WriteLine("0");
            else
                Console.WriteLine(d-a);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
unittest
{
	assert( [ "3", "0.30 0.60 0.80" ].parse.expand.solve == "0.612000000" );
	assert( [ "1", "0.50" ].parse.expand.solve == "0.500000000" );
	assert( [ "5", "0.42 0.01 0.42 0.99 0.42" ].parse.expand.solve == "0.382181587" );
	
	assert( [ "2", "0.50 0.50" ].parse.expand.solve == "0.250000000" );		// 追加ケース
}



import std.conv;
import std.format;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto ps = input.front.split.to!( real[] );
	return tuple( ps );
}

auto solve( real[] ps )
{
	// dp[ 表の枚数 ][ 裏の枚数 ] = この状況になる確率
	auto dp = new real[][]( 1 + ps.length, 1 + ps.length );
	foreach( ref dpp; dp ) dpp[] = 0;
	dp[ 0 ][ 0 ] = 1;
	foreach( i; 0L .. ps.length.signed )
	{
		foreach( j; 0L .. ps.length.signed - i )
		{
			dp[ i + 1 ][ j ] += dp[ i ][ j ] * ps[ i + j ];
			dp[ i ][ j + 1 ] += dp[ i ][ j ] * ( 1 - ps[ i + j ] );
		}
	}
	
	// 表のほうが多い確率を合計
	auto ans = 0.0L;
	foreach( i; ps.length.signed / 2 + 1 .. ps.length.signed + 1 )
	{
		ans += dp[ i ][ ps.length.signed - i ];
	}
	return format( "%0.9f", ans );
}


Measured memory_bytes: 146556
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
  int a, b;
  cin >> a >> b;
  int ret = a + b;
  ret %= 24;
  cout << ret << endl;	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        while (true) {
            int n = inScanner.nextInt();
            int r = inScanner.nextInt();

            if (n == 0 && r == 0) {
                break;
            }

            int[][] card = new int[r+1][n];
            for (int i = 0; i < n; i++) {
                card[0][i] = n - i;
            }

            for (int i = 0; i < r; i++) {
                int p = inScanner.nextInt();
                int c = inScanner.nextInt();

                for (int j = 0; j < n; j++) {
                    if (j < c) {
                        card[i+1][j] = card[i][p-1+j];
                    }
                    else if (j < (p-1)+c) {
                        card[i+1][j] = card[i][j-c];
                    }
                    else {
                        card[i+1][j] = card[i][j];
                    }
                }
            }
            System.out.println(card[r][0]);
        }
    }
}

Measured memory_bytes: 39068
/* A - Payment */

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

int main(){
  int N;
  cin >> N;
  for(int i = 0; ; i++){
    if(N > 1000 * i && N <= 1000 * (i + 1)){
      cout << 1000 * (i + 1) - N << endl;
      break;
    }
  }
}


Measured memory_bytes: 3620
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    vector<bool> row(h), col(w);
    rep(i, h) {
      cin >> s[i];
    }
    rep(i, h) {
      rep(j, w) {
        if (s[i][j] == '#') {
          row[i] = true;
          col[j] = true;
        }
      }
    }
    rep(i, h) {
      if (row[i]) {
        rep(j, w) {
          if (col[j]) {
            cout << s[i][j];
          }
        }
        cout << '\n';
      }
    }

    return 0;
}


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

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define loop(i,a,b) for(int i=a;i>=b;i--)
#define forr(x,arr) for(auto& x:arr)
#define mod 1000000007
#define INF 0x3f3f3f3f3f3f3f3f
#define EPS 1e-7
#define sz(x) ((lli)(x).size())
#define endl '\n'

#ifdef SANJU
    #define localsys 1
#else
    #define localsys 0
#endif

using   lli     =   long long;
using   lld     =   long double;
using   ulli    =   unsigned long long int;
using   pll     =   pair<lli, lli>;
using   ttt     =   pair<lli, pll>;
using   vttt    =   vector<ttt>;
using   vll     =   vector<pll>;
using   vl      =   vector<lli>;
using   vi      =   vector<int>;
using   vvi     =   vector<vector<int>>;
using   cd      =   complex<lld>;

void sanjeev(int kkkk)
{
    int n;
    cin>>n;
    vector<int>dp(3,0);
    for(int p=0;p<n;p++)
    {
        vector<int>A;
        for( int i=0;i<3;i++)
        {
            int t;
            cin>>t;
            A.push_back(t);
        }

        vector<int>ndp(3,0);
        for(int i=0;i<3;i++)
        {   
            for(int j=0;j<3;j++)
            {

                if(i!=j)
                {
                    ndp[j]=max(ndp[j],dp[i]+A[j]);
                }
            }
        }
        dp=ndp;

    }

    int ans=max({dp[0],dp[1],dp[2]});
    cout<<ans;

}

int main()
{
    if(!localsys) ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    fol(i,0,t) { sanjeev(i+1); }
    if(localsys) system("pause");
}


Measured memory_bytes: 256
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		a[i] = readInt()
	}

	b := make([]int, n+1)
	for i := n; i >= 1; i-- {
		if i+i > n {
			b[i] = a[i]
		}

		sum := 0
		for j := i + i; j <= n; j += i {
			sum += b[j]
		}
		if sum%2 == a[i] {
			b[i] = 0
		} else {
			b[i] = 1
		}
	}
	ans := make([]int, 0)
	for i := 1; i <= n; i++ {
		if b[i] == 1 {
			ans = append(ans, i)
		}
	}
	fmt.Println(len(ans))
	for _, v := range ans {
		fmt.Printf("%v ", v)
	}
}


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

int main(){
  ll a,b,c; cin >> a >>b >> c;
  ll min_bc = min(b,c);
  ll d,ans;
  
  if(b>=c){
    d = b - min_bc ;
    if(d <= a){
      ans = 2*min_bc + d;
    }else{
      ans = 2*min_bc + a +1;
    }
  }else{
    d = c - min_bc;
    if(d <= a){
      ans = 2*min_bc + d;
    }else{
      ans = 2*min_bc + a +1;
    }
  }
  cout << ans << endl;
}
    
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>c)
    {
        cout<<"NO";
        return 0;
    }
    if(a+b<c) 
    {
        cout<<"NO";
        return 0;
    }
     cout<<"YES";
}

Measured memory_bytes: 256
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define ld long double
#define beg(i ,n) for(ll i=0;i<n;i++)
#define beg1(i ,n) for(ll i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second

//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
const ll inf = 1e18 + 5 ;

//---------------------------------------------------FUNCTIONS-------------------------------------------------------

const ll nax = 2e3 + 5 ;
ll n , k ;

void add_self(ll &a , ll b){
	a+=b ;
	if(a>MOD) a-=MOD ;
}

ll mul(ll a , ll b){
	return a * b % MOD ;
}

ll dp[10005][105][2] ;

void solve(){
	string s ;
	int d ;
	cin >> s >> d ;
	for(int i=0 ; i<=s[0]-'0' ; ++i){
		if(i!=s[0]-'0') dp[1][i%d][0] += 1 ;
		else dp[1][i%d][1] += 1 ;
	}
	ll len = s.length() ;
	for(int index=1 ; index<len ; ++index){
		for(int c_mod=0 ; c_mod<d ; ++c_mod){
			for(int digit=0 ; digit<=9 ; ++digit){
				//cout << index << " " << c_mod << " " << digit << " " << (c_mod+digit)%d << nl ;
				add_self(dp[index+1][(c_mod+digit)%d][0] , dp[index][c_mod][0]) ;
			}
			for(int digit=0 ; digit<=s[index]-'0' ; ++digit){
				if(digit<s[index]-'0'){
					//cout << index << " " << c_mod << " " << digit << nl ;
					add_self(dp[index+1][(c_mod+digit)%d][0] , dp[index][c_mod][1]) ;
				}
				else{					
					//cout << index << " " << c_mod << " " << digit << nl ;
					add_self(dp[index+1][(c_mod+digit)%d][1] , dp[index][c_mod][1]) ;
				}
			}
		}
	}
	ll answer = (dp[len][0][0] + dp[len][0][1]) % MOD ;
	--answer ;
	if(answer<0) answer+=MOD ;
	printf("%lld" , answer) ;
}

//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //scanf("%lld" , &t) ;
    while(t--){
        solve() ;
        //cout << "A" << nl ;
    }
    return 0;
}   

Measured memory_bytes: 16768
N = int(input())
A = []
count_natural = 0
count_minus = 0
min = 10000000000
for p in map(int, input().split()):
  if p > 0:
    count_natural += 1
  else:
    count_minus += 1
  min = abs(p) if abs(p) < min else min
  A.append(abs(p))
if count_minus % 2 == 0:
  print(sum(A))
else:
  print(sum(A) - min * 2)

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

using namespace std;

int N;
int X[10], Y[10];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  vector<int> v(N);
  for (int i = 0; i < N; i++) {
    v.at(i) = i;
  }
  double sum = 0;
  do {
    for (int i = 0; i < N - 1; i++) {
      int s = v[i];
      int t = v[i + 1];
      int dx = X[s] - X[t];
      int dy = Y[s] - Y[t];
      sum += sqrt(dx * dx + dy * dy);
    }
  } while (next_permutation(v.begin(), v.end()));
  for (int i = 2; i <= N; i++) {
    sum /= i;
  }
  cout << fixed << setprecision(10) << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
      string s , t ,u;
      int a , b;
      cin >> s >> t;
      cin >> a >> b;
      cin >> u;
      if(u == s)
            a--;
      else
            b--;
      cout << a << " " << b;

    return 0;
}


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

int main(){
  string N;
  cin >> N;
  
  long long cnt = 0;
  for(int i=0;i<N.size();i++){
    cnt += N[i] - '0';
  }
  
  if(cnt%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)


////////////////////////////////////////////////////////////
int a,b,c,d,e,f;
int ans_k;
int ans_s;

bool dp[3000][3000];

void solve( int k , int s ){
	
	//cout << "k:" << k << " s:" << s << endl;
	
	if( dp[k][s] )
		ret;

	dp[k][s] = 1;

	int w =( k - s );

	if( double(ans_s)/ans_k < double(s)/k  ){
		ans_s = s;
		ans_k = k;
	}

	if( k > f )
		ret;

	if( s+c <= double(w)/100*e && c+k <= f){
		solve( k + c , s + c );
	}
	
	if( s+d <= double(w)/100*e && d+k <= f){
		solve( k + d , s + d );
	}
	
	if( k + 100*a <= f )
		solve( k + 100*a , s );

	if( k + 100*b <= f )
		solve( k + 100*b , s );
	
}
int main(){
	cin >> a >> b >> c >> d >> e >> f;
	ans_s = 0;
	ans_k = a*100;
	solve( 0 , 0 );

	cout << ans_k << " " << ans_s << endl;
	ret 0;
}

Measured memory_bytes: 6784
from re import*
s,t=open(0)
t=t[:-1]
u=''.join('(%s|\?)'%t for t in t)
a=[]
j=len(t)
for i in range(len(s)-j):
  if match(u,s[i:i+j]):
    a.append(sub('\?','a',s[:i])+t+sub('\?','a',s[i+j:]))
print(min(a or['UNRESTORABLE']))

Measured memory_bytes: 3188
#include <iostream>

#define N_MAX 200000

using namespace std;

long a[N_MAX];
long cumsum[N_MAX];

long calc_min_diff(long B, long C, long D, long E);

int main(){
    int N;
    int left, center, right;
    long min_diff, prev_diff;
    long B, C, D, E;
    cin >> N;
    cin >> a[0];
    cumsum[0] = a[0];
    for(int i = 1; i < N; i++){
        cin >> a[i];
        cumsum[i] = cumsum[i -1] + a[i];
    }
    
    left = 1;
    right = 3;
    min_diff = __LONG_MAX__;
    
    for(center = 2; center <= N - 2; center++){
        //B, C
        prev_diff = __LONG_MAX__;
        while(left < center){
            B = cumsum[left - 1];
            C = cumsum[center - 1] - cumsum[left - 1];
            if(abs(B - C) > prev_diff){
                B = cumsum[left - 2];
                C = cumsum[center - 1] - cumsum[left - 2];
                left--;
                break;
            }
            if(left + 1 == center){break;}
            
            prev_diff = abs(B - C);
            left++;
        }
        //D, E
        prev_diff = __LONG_MAX__;
        while(right < N){
            D = cumsum[right - 1] - cumsum[center - 1];
            E = cumsum[N - 1] - cumsum[right - 1];
            if(abs(D - E) > prev_diff){
                D = cumsum[right - 2] - cumsum[center - 1];
                E = cumsum[N - 1] - cumsum[right - 2];
                right--;
                break;
            }
            if(right + 1 == N){break;}
            prev_diff = abs(E - D);
            right++;
        }
        if(min_diff > calc_min_diff(B, C, D, E)){
            min_diff = calc_min_diff(B, C, D, E);
        }
    }
    cout << min_diff << '\n';
}

long calc_min_diff(long B, long C, long D, long E){
    long min, max;
    if(B <= C && B <= D && B <= E){
        min = B;
    }
    else if(C < B && C <= D && C <= E){
        min = C;
    }
    else if(D < B && D < C && D <= E){
        min = D;
    }
    else{
        min = E;
    }

    if(B >= C && B >= D && B >= E){
        max = B;
    }
    else if(C > B && C >= D && C >= E){
        max = C;
    }
    else if(D > B && D > C && D >= E){
        max = D;
    }
    else{
        max = E;
    }
    return max - min;
}

Measured memory_bytes: 3328
using System;

namespace atcoderA
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);
            int ans = A + B;
            if (ans >= 24)
            {
                ans -= 24;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
from sys import stdin


def main():
    s = input()

    best = 0
    cnt = 0
    flg = False

    for v in s:
        if v == 'A':
            flg = True
        if flg:
            cnt += 1
        if flg and v == 'Z':
            best = cnt

    print(best)


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3516
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

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

	long long N;
	map<int, int> mp;

	cin >> N;
	for(int i = 0; i < N; i++){
		int v;
		cin >> v;
		if(mp.count(v) == 0){
			mp[v] = 1;
		}
		else{
			mp[v]++;
		}
	}
	int ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		int k = itr->first;
		int v = itr->second;
		if(v > k){
			ans += (v - k);
		}
		else if(v < k){
			ans += v;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4736
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define INF 999999999
int m,n;
vector< vector<int > > S;
vector<int> F;

void init(){
  m=n=0;
  S.resize(0);
  F.resize(0);
}

void input(){
  cin>>m>>n;
  m++;
  F.resize(m);
  S.resize(m);
  for(int i=0;i<m;i++){
    F[i]=0;
  }
  F[0]=INF;
  for(int i=0;i<n;i++){
    int f,s;
    cin>>f>>s;
    F[s]++;
    S[f].push_back(s);
  }
}

int find_zero(){
  for(int i=0;i<m;i++){
    if(F[i]==0){
      F[i]=INF;
      return i;
    }
  }
}

void hoge(int n){
  for(int i=0;i<S[n].size();i++){
    F[S[n][i]]--;
  }
}

vector<int> solve(){
  vector<int> res;
  
  for(int i=1;i<m;i++){
    int num=find_zero();
    hoge(num);
    res.push_back(num);
  }

  return res;
}

int main(){
  init();
  input();
  vector<int> ans = solve();
  for(int i=0;i<ans.size();i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<int> c(a);
  for(int i = 0;i < a;i++){
    cin >> c.at(i);}
    long long s;
    for(int i = 0;i < a;i++){
      for(int j = 0;j < i;j++){
        s += c.at(i)*c.at(j);
      }
    }
  cout << s << endl;
  }

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

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n, r;
	cin >> n >> r;
	if (500 * n >= r) {
		cout << "Yes";

	}
	else {
		cout << "No";
	}

}

Measured memory_bytes: 3572
# C - Maximal Value
n = (int)(input())
b = list(map(int, input().split()))

a = [0] * n

for i in reversed(range(0, n)):
    if i == n - 1: a[i] = b[i-1]
    elif i == 0: a[i] = b[0]
    else: a[i] = min(b[i], b[i-1])

print(sum(a))

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n, m;
    cin >> n >> m; 

    vll dp(n * 1000 + 1, INF);
    for (int i = 0; i < n; i++) {
        vll dp_ = dp;
        ll w, v;
        cin >> w >> v;
        dp_[v] = min(dp[v], w);
        for (int i = 1; v + i <= dp.size(); i++) {
            if (dp[i] != INF and dp[i] + w <= m)
                dp_[i + v] = min(dp_[i + v], dp[i] + w);
        }
        swap(dp, dp_);
    }
    for (int i = dp.size() - 1; i >= 0; i--) {
        if (dp[i] <= m) {
            cout << i << '\n';
            return 0;
        }
    }
}


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

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


Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define int long long int
#define inf 100000000000
#define hell (int)(998244353)

using namespace std;

bool ispal(string s){
    string s1=s;
    reverse(begin(s1),end(s1));
    return s==s1;
}

void solve(){
    string s;
    cin>>s;
    int l=s.length();
    if(ispal(s)&&ispal(s.substr(0,l/2))&&ispal(s.substr(l/2+1)))
        cout<<"Yes";
    else
        cout<<"No";
}

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
	return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    int counter=0;

    for(int i=a;i<=b;i++){
        if(i/10000==i%10 && (i/1000)%10==(i%100)/10){
            counter++;
        }
    }
    cout <<counter<<endl;
}

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

#define pf push_front
#define pb push_back
#define F first
#define S second
#define mp make_pair

using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
typedef pair <llong, llong> pllong;

const llong MXN = 1e6 + 7;
const llong MOD = 1e9 + 7;
const llong INF = 2e18 + 7;

inline void Need_for_speed()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

string s;
const string dx[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
const int ans[] = {7, 6, 5, 4, 3, 2, 1};

int main ()
{
  //freopen("Notail.in", "r", stdin);
  //freopen("Notail.out", "w", stdout);
  cin >> s;
  for(int i = 0; i < 7; i++){
    if(dx[i] == s){
      cout << ans[i];
    }
  }
  exit(0);
}


Measured memory_bytes: 256
using System;
class MainClass
{
    public static void Main(string[] args)
    {

        string[] s1 = Console.ReadLine().Split(' ');
        long X = long.Parse(s1[0]);
        long Y = long.Parse(s1[1]);
        int ans = 0;

        long i = X;

        while(i<=Y)
        {

            ans++;

            i = i * 2;

        }
            
        //for (int i = X; i <= Y;i++)
        //{
         


        //}


        Console.WriteLine(ans);

    }
}



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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if (a.Substring(5, 2) == "04" && a.Substring(8, 2) == "31")
                Console.WriteLine("TBD");
            else if (a.Substring(5, 2) == "04" && a.Substring(8, 2) != "31")
                Console.WriteLine("Heisei");
            else if (a.Substring(5, 2) == "03")
                Console.WriteLine("Heisei");
            else if (a.Substring(5, 2) == "02")
                Console.WriteLine("Heisei");
            else if (a.Substring(5, 2) == "01")
                Console.WriteLine("Heisei");
            else
                Console.WriteLine("TBD");
            Console.ReadKey();

            
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int K;
int a[32] = {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};

int main() {
    cin >> K;

    cout << a[K-1] << endl;

    
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a, b, c;
	char op;
	while(1){
	scanf("%d %c %d", &a, &op, &b);
	if(op == '+'){
		c = a + b;
	}else if(op == '-'){
		c = a - b;
	}else if(op == '*'){
		c = a * b;
	}else if(op == '/'){
		c = a / b;
	}else{
		break;
	}
	printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int r=0;
        HashMap<String, Boolean> map=new HashMap<>();
        for (int i = 0; i < n; i++) {
			String s=sc.nextString();
			if(map.containsKey(s))continue;
			map.put(s, true);
			r++;
		}
    
        out.println(r);
     	out.flush();
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


//class P implements Comparable<P>{
//    int i,x,r,f;
//    P(int i,int x,int r,int f) {
//    	this.i=i;
//    	this.x=x;
//    	this.r=r;
//    	this.f=f;
//    }
//
//    public int compareTo(P p){
//    	if(-this.r+p.r==0) {
//    		return -this.x+p.x;
//    	}
//        return -this.r+p.r;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 72764
n,k = map(int,input().split())
h = input().split()
h_list = [int(s) for s in h]
cost = [0 for i in range(n)]
for i in range(n):
    if i == 0:
        cost[i] = 0
        continue
    if i == 1:
        cost[i] = abs(h_list[i] - h_list[i - 1])
        continue
    k_list = []
    for j in range(k):
        if i - j - 1 < 0:
            break
        k_list.append(cost[i - j - 1] + abs(h_list[i] - h_list[i - j - 1]))
    cost[i] = min(k_list)
print(cost[n - 1])


Measured memory_bytes: 56544
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const int MOD = 998244353;
const ll INF = 1000000000000000000;

/*
・最終的な文字列は2文字からなる。
・先頭と末尾が同じとき最終的な長さは奇数。
・違うときは偶数。
|S|=9 S[0]!=S[8] 1 1 First
|S|=9 S[0]==S[8] 1 0 Second
|S|=8 S[0]!=S[7] 0 1 Second
|S|=8 S[0]==S[7] 0 0 FIrst
*/
int main()
{
	string S;
	cin >> S;
	int L = S.size();
	int c = (S[0] == S[L - 1]) ? 0 : 1;
	L %= 2;
	if (L ^ c) cout << "Second" << endl;
	else cout << "First" << endl;
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

vector<string> S(100010);  // mod kごとにわける

int main() {
    int n,k,r,s,p;
    string T;
    ll ans = 0;
    cin >> n >> k >> r >> s >> p;
    cin >> T;
    for (int i = 0; i < n; ++i) {
        if(i >= k){
            if(T[i-k] == T[i]){
                T[i] = 'a';
            }else{
                if(T[i] == 'r') ans += p;
                if(T[i] == 's') ans += r;
                if(T[i] == 'p') ans += s;
            }
        }else{
            if(T[i] == 'r') ans += p;
            if(T[i] == 's') ans += r;
            if(T[i] == 'p') ans += s;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;

int main() {
    int i;
    int k;
    
    scanf("%d", &k);
    
    for (i=0; i<k; i++) {
        int c, a, n;
	int x, y, z;
	int sum = 0;

	scanf("%d %d %d", &c, &a, &n);

	x = min(c, min(a, n));
	c -= x;
	a -= x;
        n -= x;

        y = min(c/2, a);
	c -= y * 2;
	a -= y;

	z = c/3;

	printf("%d\n", x + y + z);
    }
}

Measured memory_bytes: 1028
import random


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def lcm(a, b):
    return (a * b) / gcd(a, b)

s=input()
c=0
a=[]
for i in s:
    if i=='R':
        c+=1
    else:
        a.append(c)
        c=0
a.append(c)
print(max(a))


Measured memory_bytes: 9548