akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(void){
	int n, m;
	while(cin >> n >> m, n+m){
		vector<int> p(m, 0);
		for (int i = 0; i < n; ++i)
		{
			int d, v;
			cin >> d >> v;
			d--;
			p[d] = max(p[d], v);
		}
		int sum = 0;
		for(int i = 0; i < m; ++i){
			sum += p[i];
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3092
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

using Flow = int;
struct FlowEdge {
  int src, dst, rev;
  Flow cap;
  FlowEdge(const int s = 0, const int d = 0, const Flow c = 0, const int r = 0) : src(s), dst(d), cap(c), rev(r) {}
};

using FlowEdges = std::vector<FlowEdge>;

class FlowGraph {
  std::vector<FlowEdges> g;

public:
  FlowGraph(const int size = 0) : g(size) {}
  size_t size() const { return g.size(); }
  FlowEdges &operator[](const int i) & { return g[i]; }

  void addEdge(const int src, const int dst, const Flow c = 1) {
    g[src].emplace_back(src, dst, c, g[dst].size());
    g[dst].emplace_back(dst, src, 0, g[src].size() - 1);
  }
};

template<int inf = std::numeric_limits<Flow>::max() / 8> Flow fordFulkerson(FlowGraph g, const int source, const int sink) {
  std::vector<int> used;
  std::function<int(int, int, int)> dfs = [&](int s, int t, int f) -> int {
    if (s == t) return f;
    used[s] = true;
    for (auto &e : g[s]) {
      if (used[e.dst] || e.cap <= 0) continue;
      int d = dfs(e.dst, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.dst][e.rev].cap += d;
        return d;
      }
    }
    return 0;
  };
  Flow s = 0;
  for (;;) {
    used.assign(g.size(), false);
    Flow f = dfs(source, sink, inf);
    if (f == 0) return s;
    s += f;
  }
}

main {
  int n, m;
  cin >> n >> m;
  FlowGraph g(n);
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    g.addEdge(a, b, c);
  }
  cout << fordFulkerson(g, 0, n - 1) << endl;
}

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


int main() 
{
    string a,b;
    cin>>a>>b;
    int c=0;
    for(int i=0;i<a.length();i++)
    {
        if(a[i]!=b[i])
            c++;
    }
    cout<<c;
}



/*
7
9
6


*/

Measured memory_bytes: 3916
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>


int main(int argc, char *argv[])
{
	string s;
	cin >> s;
	s[0]++;

	cout<< s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAX_NODE 110

int main() {
    char str[150];
    scanf("%s", str);
    int len = strlen(str);
    printf("%c%d%c\n", str[0],len - 2, str[len - 1]);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll mod=1000000007; // 998244353 = (119<<23)+1
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
// head
int n,m;
priority_queue<pii> pq;
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n>>m;
		rep(i,0,n) {
			int b;
			ll a;
			cin>>a>>b;
			pq.push(mp(-a,b));
		}
		ll ans=0;
		while(m>0) {
			ll quant=min(pq.top().se,m);
			m-=quant;
			ans+=quant*-1LL*pq.top().fi;
			pq.pop();
		}
		cout<<ans;
		return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
int main()
{
    char s[200];
    scanf("%s", s);

    int len = 0;
    for(int i = 0; s[i] != 0 ; i++)
        len++;

    int cnt = 0;
    for(int i = 0, j =len-1; i <= j ; i++, j--)
    {
        if(s[i] != s[j])
        {
            cnt++;
        }
    }
    printf("%d", cnt);
    return 0;
}


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

int ma[10] = { 0,2,5,5,4,5,6,3,7,6 };

// dp[i] : i本使った時の最大値
string dp[10020];

void str_max( string& a, string& b ) {
  if ( a.size() < b.size() ) {
    a = b;
  } else if ( a.size() == b.size() ) {
    if ( b > a ) a = b;
  }
  return;
} 
int main() {
  int N, M;
  cin >> N >> M;
  vector< int > A(M);
  REP(i,M) {
    cin >> A[i];
  }
  // "-"を初期値とする。初期値の場合は、その本数になることがないことを示す。
  // はじめは不要かと思ってたけど、dp[0] = "" の状態と、存在しないは違う。
  // 存在しない場合はそのdp[i]を起点とすることができない。
  REP(i,N) dp[i] = "-";

  dp[0] = "";
  REP(i,N+1) {
    for ( auto x: A ) {
      // 存在しない場合は飛ばす
      if ( dp[i] == "-" ) continue;
      string b = dp[i] + (char)('0'+x);
      str_max( dp[i+ma[x]], b );
    }
  }
  
  cout << dp[N] << endl;
}


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

int n, fa[100005], sz[100005], depth[100005];
std::vector<int> to[100005];

int DFS(int now) {
	sz[now] = 1;
	for (auto i: to[now]) {
		if (i == fa[now]) continue;
		fa[i] = now;
		depth[i] = depth[now] + 1;
		sz[now] += DFS(i);
	}
	return sz[now];
}

int main() {
	std::cin >> n;
	for (int u, v, i = 1; i < n; ++i) {
		std::cin >> u >> v;
		to[u].push_back(v);
		to[v].push_back(u);
	}
	
	depth[1] = 1;
	DFS(1);
	
	int k = n;
	while (depth[k] != ((depth[1] + depth[n]) >> 1) + 1) k = fa[k];
	
	puts(n - sz[k] > sz[k] ? "Fennec" : "Snuke");
	
	return 0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
#define ll long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define clr(x,y) memset(x,y,sizeof(x))
#define in(a) a=read()
#define out(a) printf("%d\n",a)
inline ll read(){
    char c=getchar();ll f=1,x=0;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+(c-'0'),c=getchar();
    return x*f;
}
#define mod 1000000000000ll
#define maxn 100010
#define inf (1ll<<60)
int s[maxn];
int main(){
	int n,m,q;
	in(n);in(m);in(q);
	FOR(i,1,q){
		int x;
		in(x);
		s[x]++;	
	}
	FOR(i,1,n)
		if(s[i]+m-q<=0)puts("No");
		else puts("Yes");
}

Measured memory_bytes: 1024
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd_int(void){
  int x;
  rd(x);
  return x;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int X;
int dame[1000];
int main(){
  int Lj4PdHRW, i;
  int res;
  int opt = 1073709056;
  int dis;
  rd(X);
  int KL2GvlyY = rd_int();
  for(Lj4PdHRW=(0);Lj4PdHRW<(KL2GvlyY);Lj4PdHRW++){
    dame[rd_int()] = 1;
  }
  for(i=(0);i<(1000);i++){
    if(dame[i]==0){
      dis = abs(X-i);
      if(opt > dis){
        opt = dis;
        res = i;
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200509-1

// --- original code ---
// int X, dame[1000];
// {
//   int res, opt = int_inf, dis;
//   rd(X);
//   REP(rd_int()) dame[rd_int()] = 1;
//   rep(i,1000) if(dame[i]==0) {
//     dis = abs(X-i);
//     if(opt > dis) opt = dis, res = i;
//   }
//   wt(res);
// }


Measured memory_bytes: 3632
n,k=gets.chomp.split.map(&:to_i)
x=gets.chomp.split.map(&:to_i)

if x[0]>=0
    puts x[k-1]
    exit
end
if x[n-1]<=0
    puts -x[n-k]
    exit
end

minus = []
plus = []
x.each do |v|
    if v >= 0
        plus << v
    else
        minus << v
    end
end
minus.reverse!
#p plus
#p minus
ans = 10 ** 10
0.upto(k) do |i|
    next if i >= plus.size
    next if k-i-2 >= minus.size
    next if k-i-2 <0
    t = plus[i] - minus[k-i-2] + [plus[i].abs, minus[k-i-2].abs].min
    if t < ans
        ans = t
    end
end
puts ans

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

int main() {
  int k;
  cin >> 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};
  cout << a[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
N,K,Q = map(int,input().split())
point = [0]*(N+1)
for i in range(Q):
    point[int(input())]+=1
if K <= Q:
    for i in range(1,N+1):
        print("No"if Q - point[i] >= K else "Yes")
else:
    for i in range(N):
        print("Yes")

Measured memory_bytes: 4680
type ary=array[1..55] of int64;
var n,m:int64;
    v:ary;
    sum:real;
    
procedure sort(p,q :integer; var a:ary);
  var i, j, k, w :integer;
begin i := p; j := q; k:=a[(p+q) div 2];
  repeat
    while a[i] < k do inc(i);
    while k < a[j] do dec(j);
    if i <= j then begin
      w := a[i]; a[i] := a[j]; a[j] := w;
      inc(i);dec(j);
    end
  until i > j;
  if p < j then sort(p,j,a);
  if i < q then sort(i,q,a)
end;    
    
    
begin
read(n);
for m := 1 to n do read(v[m]);
sort(1,n,v);
sum:=v[1];
for m := 2 to n do 
 sum:=(sum+v[m])/2;

write(sum)
end.

Measured memory_bytes: 128
#include<stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int M[MAX][MAX],n;
int prim(void);
int main()
{
  int i,j,s;
  scanf("%d",&n);


  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&s);
      if(s==-1)M[i][j] = 1000000;
      else M[i][j] =  s;
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim()
{
  int u,min,sum,v,i;
  int d[MAX],p[MAX],color[MAX];

  for(i=0;i<n;i++){
      d[i] = 100000;
      p[i] = -1;
      color[i]=WHITE;
    }

	d[0] = 0;


      while(1)
	{
	  min = 100000;
	  for(i=0;i<n;i++)
	    {
	      if(color[i] != BLACK && d[i] < min)
		{
		  min = d[i];
		  u=i;
		}
	    }
	  if(min == 100000) break;
	  color[u] = BLACK;
	  for(v=0;v<n;v++)
	    {
	      if(color[v] != BLACK && M[u][v] != 100000)
		{
		  if(d[v] >M[u][v])
		    {
		      d[v] = M[u][v];
		      p[v] = u;
		      color[v] = GRAY;
		    }
		}
	    }
	}
	sum=0;
      for(i=0;i<n;i++)
	{
	  if(p[i] != -1)sum += M[i][p[i]];
	}
	
	return sum;
}



Measured memory_bytes: 2044
import java.util.Scanner;

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

		String w = sc.nextLine();

		int result = 0;
		while (true) {
			String t1 = sc.nextLine();
			if ("END_OF_TEXT".equals(t1)) {
				break;
			}
			t1 = t1.toLowerCase();

			String[] arr = t1.split(" ");

			for (int i = 0; i < arr.length; i++) {
				if (w.equals(arr[i])) {
					result++;
				}
			}

		}
		System.out.println(result);

		sc.close();

	}
}


Measured memory_bytes: 26376
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let a = scan.readn::<i64>(n);
    if a.iter().all(|x| *x % 2 == 0) {
        println!("second");
    } else {
        println!("first");
    }
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

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

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#import pandas as pd
n=int(input())
O=[]
#A=[]
#B=[]
for i in range(n):
    a,b=map(int, input().split(" "))
    O.append([a+b,a,b])
  
#O=sorted(O, key=lambda x: (x[0],x[1]))[::-1]
O=sorted(O, key=lambda x: (x[0]))[::-1]
#print(O)

count=0
for num in range(n):
    if num%2==0:
        count+=O[num][1]
    else:
        count-=O[num][2]

print(count)


Measured memory_bytes: 26844
#include<iostream>
#include<cstdio>

using namespace std;

int main()
{
	int n;
	int i,j;
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		int table[12][12]={0};
		
		for(i=0;i<n;i++)
		{
			for(j=0;j<n;j++)
			{
				cin >> table[i][j] ;
			}
		}
		
		for(i=0;i<=n;i++)
		{
			for(j=0;j<=n;j++)
			{
				if(j!=n)
				{
					printf("%5d",table[i][j]);
					table[i][n]+=table[i][j];
					table[n][j]+=table[i][j];
				}
				else
					printf("%5d\n",table[i][j]);
			}
		}
	}
}

Measured memory_bytes: 0
n,k = map(int,input().split())
P = list(map(int,input().split()))
Q = []
for i in range(n):
    Q.append((P[i]-1)/2 + 1)
R = [Q[0]]
for i in range(1, n):
    R.append(R[-1] + Q[i])
l = 0
r = R[k-1]
ans = r-l
for i in range(n-k):
    ans = max(ans, R[k+i]-R[i])
print(ans)

Measured memory_bytes: 78984
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));
		String readline = br.readLine();

		String[] set = readline.split(" ");

		int a = Integer.parseInt(set[0]);
		int b = Integer.parseInt(set[1]);
		int c = Integer.parseInt(set[2]);
		int temp = 0;
		if (c < b) {
			temp = b;
			b = c;
			c = temp;
		}
		if (b < a) {
			temp = a;
			a = b;
			b= temp;
		}
		if (c < b) {
			temp = b;
			b = c;
			c = temp;
		}
		System.out.println(a + " " + b + " " + c);
	}

}

Measured memory_bytes: 24164
INF = int(1e9+7)


def primeNumber(n, pn):
    # Sieve of Eratosthenes
    b = [True] * (n + 1)
    for i in range(2, n + 1):
        if b[i]:
            pn.append(i)
            for j in range(i, n + 1, i):
                b[j] = False
    return


def main():
    N = int(input())
    pn = []
    primeNumber(N, pn)
    ans = 1
    for p in pn:
        cnt = 0
        cum = p
        while cum <= N:
            cnt += N // cum
            cum *= p
        ans = ans * (cnt + 1) % INF
    print(ans)


main()


Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
using namespace std;

int main(){
    int x1;
    int x2;
    int x3;
    int x4;
    int x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0)cout<<1;
     if(x2==0)cout<<2;
      if(x3==0)cout<<3;
       if(x4==0)cout<<4;
        if(x5==0)cout<<5;
return 0;
}

Measured memory_bytes: 3108
N = int(input())

if N >= 64:
    print(64)
elif N >= 32:
    print(32)
elif N >= 16:
    print(16)
elif N >= 8:
    print(8)
elif N >= 4:
    print(4)
elif N >= 2:
    print(2)
else:
    print(1)

Measured memory_bytes: 9124
import math
import time


t = time.time()
def iip():
    ret = [int(i) for i in input().split()]
    if len(ret) == 1:
        return ret[0]
    return ret

def fkc(keta):
    return 10**keta

def pat_b(a, n):
    tail = a % 10

    if tail == 0:
        return 0

    head = int(str(a)[0])

    ret = 0
    if tail == head: #１桁解
        ret += 1

    if n >= tail*10+head: #２桁解は１通りあるかないか
        ret += 1

    for free_keta in range(1, 6): # 3桁以上解
        mincase = 10**(free_keta+1) * tail + head

        if n < mincase:
            break
        if n >= 10**(free_keta+1) + mincase + head - 10:
            ret += fkc(free_keta)
            continue
        else:
            ret += int(int(n-mincase)/10) + 1
    return ret

def main():
    n = iip()
    result = 0
    for i in range(n+1):
        result += pat_b(i, n)
    print(result)


main()

Measured memory_bytes: 44392
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t, x;
	
	cin >> t >> x;
	cout << setprecision(10) << fixed << t * 1.0 / x << "\n";

	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<vector<ll>>d(k);
  rep(i,0,k){
    ll x;cin>>x;
    rep(j,0,x){
      ll y;cin>>y;
      d[i].PB(y);
    }
  }
  vector<ll>cnt(n);
  rep(i,0,k){
    for(auto z:d[i])cnt[z-1]++;
  }
  rep(i,0,n)if(cnt[i]==0)res++;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3664
from collections import deque
def main():
    n,k = map(int,input().split())
    ls = [int(x) for x in input().split()]
    ls_r = [0]*(n+1)
    for i in range(n):
        ls_r[i+1] = ls_r[i]+ls[i]
    ls_l = [0]*(n+1)
    for i in range(n):
        ls_l[i+1] = ls_l[i]+ls[i]

    ans = 0
    for i in range(min(k,n)+1):
        for j in range((min(k,n)+1)-i):
            now = ls[:i] + ls[n-j:] + [0]
            now = sorted(now)
            can = sum(now)
            now = deque(now)
            roop = 0
            while 1:
                if  roop == k-(i+j):
                    break
                
                pop = now.popleft()
                if pop>=0:
                    break
                else:
                    can -= pop
                roop += 1
            ans = max(can,ans)
    print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 39792
#include <iostream>
using namespace std;
int main(void){
  long long int A,B,C,K;
  cin >> A >> B >> C >> K;
  long long int sum =0;
  
  if(A >= K) {
   	sum = K;
    cout << sum << endl;
    return 0;
  }
  
  else
  {
    K -= A;
    sum += A;  
 
    if(B >= K)
    {
      cout << sum << endl;
      return 0; 
    }
    
    else
    {
      K -= B;
      sum -= K;
      cout << sum << endl;
      return 0;
  	}
  }
  return 0;
}

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

int main(){
  string str1,str2;
  cin>>str1;
  cin>>str2;
  if(str1.size()>str2.size()){
    for(int i=0;i<str2.size();i++){
      cout<<str1[i];
      cout<<str2[i];
    }
    cout<<str1[str1.size()-1];
  }
  else{
    for(int i=0;i<str1.size();i++){
      cout<<str1[i];
      cout<<str2[i];
    }
  }
}

Measured memory_bytes: 256
from collections import deque
from itertools import product
import sys
input=sys.stdin.readline


def solve():
    H, W = map(int, input().split())
    Ch, Cw = map(int, input().split())
    Dh, Dw = map(int, input().split())

    l = [[1 if i=="#" else 0 for i in input()] for _ in range(H)]
    q = deque([(0, (Ch-1, Cw-1))])
    INF = 10**12
    costs = [[INF]*W for _ in range(H)]
    costs[Ch-1][Cw-1] = 0

    while q:
        cost, pos = q.popleft()
        h, w = pos

        for dh, dw in product(range(-2,3), repeat=2):
            if dh==0 and dw==0:
                continue
            hh, ww = h+dh, w+dw
            if not (0<=hh<H and 0<=ww<W):
                continue
            if l[hh][ww]:
                continue
            
            if ((abs(dh)==1 and dw==0) or (dh==0 and abs(dw)==1)) and costs[hh][ww] > costs[h][w]:
                costs[hh][ww] = costs[h][w]
                q.appendleft((cost, (hh, ww)))
            elif costs[hh][ww] > costs[h][w]+1:
                costs[hh][ww] = costs[h][w]+1
                q.append((cost+1, (hh, ww)))

    ans = costs[Dh-1][Dw-1]
    print(ans if ans!=INF else -1)


solve()


Measured memory_bytes: 126384
import java.util.*;
import java.math.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int tap = 1;
    int atap = 0;
    
    while(tap < b){
      tap--;
      tap += a;
      atap++;
    }
    
    System.out.println(atap);
    
    
  }
}

Measured memory_bytes: 35740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=1000100,mod=998244353;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
inline int qmo(int x){return x+(x>>31)*mod;}
int n,p[maxn],cnt,ch[maxn][26],sum[maxn][26],lst[26];
string s[maxn];
ll ans;
inline bool cmp(int x,int y){
	return s[x].size()>s[y].size();
}
void insert(string s){
	int now=0,len=s.size();
	FOR(i,0,25) lst[i]=-1;
	FOR(i,0,len-1) lst[s[i]-'a']=i;
	FOR(i,0,len-1){
		FOR(j,0,25) if(lst[j]>=i) sum[now][j]++;
		int p=s[i]-'a';
		if(!ch[now][p]) ch[now][p]=++cnt;
		now=ch[now][p];
	}
}
int query(string s){
	int now=0,len=s.size();
	FOR(i,0,len-2){
		int p=s[i]-'a';
		if(!ch[now][p]) return 0;
		now=ch[now][p];
	}
	return sum[now][s[len-1]-'a'];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n;
	FOR(i,1,n) cin>>s[i],reverse(s[i].begin(),s[i].end());
	FOR(i,1,n) p[i]=i;
	sort(p+1,p+n+1,cmp);
	FOR(i,1,n) ans+=query(s[p[i]]),insert(s[p[i]]);
	printf("%lld\n",ans);
}

Measured memory_bytes: 238924
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String o = sc.next();
        String e = sc.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < o.length(); i++) {
            sb.append(o.charAt(i));
            if (i != o.length() - 1) {
                sb.append(e.charAt(i));
            } else if (o.length() == e.length()) {
                sb.append(e.charAt(i));
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 21844
use std::collections::VecDeque;

fn main(){
  loop {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1];

    if n == 0 && m == 0 { break; }

    let mut mp: Vec<Vec<char>> = vec![vec!['.'; n+2]; m+2];
    let mut dv: Vec<Vec<usize>> = vec![vec![10000; n+2]; m+2];
    
    let mut si: usize = 0;
    let mut sj: usize = 0;
    
    for i in 1 .. m+1 {
      let ts: String = read();
      let tl: Vec<char> = ts.chars().collect();
      for j in 1 .. n+1 {
        mp[i][j] = tl[j-1];
        if mp[i][j] == '&' { si = i; sj = j; }
      }
    }
    
    dv[si][sj] = 0;
    
    let mut que: VecDeque<(usize, usize)> = VecDeque::new();
    que.push_back((si, sj));
    
    let d: Vec<(isize, isize)> = vec![(1,0),(-1, 0), (0, 1), (0, -1)];
    
    loop {
      match que.pop_front() {
        None => { break; },
        Some((i, j)) => {
          for &(di, dj) in &d {
            let ti = (i as isize) + di;
            let tj = (j as isize) + dj;
            if ti < 0 || tj < 0 || ti > (m as isize)+1 || tj > (n as isize)+1 { continue; }
            let ni: usize = ti as usize;
            let nj: usize = tj as usize;
            let tc: usize =  dv[i][j] + if mp[i][j] != '#' && mp[ni][nj] == '#' {1} else {0};
            if tc < dv[ni][nj] {
              dv[ni][nj] = tc;
              que.push_back((ni, nj));
            }
          }
        },
      }
    }
    println!("{}", dv[0][0]);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5056
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef vector<ll> vi;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;

int main() {
  ll n;
  cin >> n;
  vi a(n);
  vi b(n+1,0);
  rep(i,n){
    cin >> a[i];
    b[a[i]]++;
  }
  
  ll count=0;
  rep(i,n){
    count+=b[i+1]*(b[i+1]-1)/2;
  }
  
  rep(i,n){
    cout << count-b[a[i]]+1 << endl;
  }
}

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

int main() {
	int h;
	cin >> h;
	int w;
	cin >> w;
	vector<string> a(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}

	vector<bool> row(h, false);
	vector<bool> col(w, false);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				row[i] = true;
				col[j] = true;
			}
		}
	}

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
const int INF=1001001001;
int main(){
  int n,m;
  cin>>n>>m;
  int a,b;
  vector<int> to[100005];
  for(int i=0;i<m;i++){
    cin>>a>>b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vector<int> dist(n,INF);
  vector<int> pre(n,-1);
  dist[0]=0;
  q.push(0);
  while(!q.empty()){
    int v=q.front();
    q.pop();
    for(int u:to[v]){
      if(dist[u]!=INF) continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  for(int i=0;i<n;i++){
    if(i==0) continue;
    int ans=pre[i];
    ans++;
    cout<<ans<<endl;
  }
  return 0;
}


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

int main() {
    string s;
    cin >> s;
    if (s == "A") cout << 'T' << endl;
    if (s == "T") cout << 'A' << endl;
    if (s == "G") cout << 'C' << endl;
    if (s == "C") cout << 'G' << endl;
    return 0;
}

Measured memory_bytes: 256
def get_divisor(n):
    ret = []
    for i in range(3, n + 1, 2):
        if n % i == 0:
            ret.append(i)
    return ret


def get_dec(x, MOD):
    b = 1
    t = 0
    for c in x[::-1]:
        if c == '1':
            t = (t + b) % MOD
        b = b * 2 % MOD
    return t


def count_head_smaller(x, y, d, t, MOD):
    p = x[:t]
    q = y[:t]
    k = get_dec(p, MOD)
    r = (p + q) * (d // 2) + p
    if x >= r:
        k += 1
    return k


def solve(n, x):
    MOD = 998244353
    divisors = get_divisor(n)
    divisors.reverse()
    checked_divisors = {}

    y = ''.join('1' if c == '0' else '0' for c in x)

    ans = 0
    short = 0
    for d in divisors:
        t = n // d
        k = count_head_smaller(x, y, d, t, MOD)

        for pd, pk in checked_divisors.items():
            if pd % d != 0:
                continue
            k -= pk

        ans = (ans + 2 * t * k) % MOD
        short += k
        checked_divisors[d] = k

    t = (get_dec(x, MOD) + 1 - short) % MOD
    ans = (ans + t * 2 * n) % MOD
    return ans


n = int(input())
x = input()
print(solve(n, x))


Measured memory_bytes: 5220
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <iostream>
#include <queue>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>
#include <set>
#define FOR(i,n) for(int i=0;i<n;++i)
#define _CRT_SECURE_NO_WARNINGS
using namespace std;

using ti = tuple < int, int, int >;
using lint = long long;
using ii = pair < int, int >;
using ll = pair < lint, lint >;

int main() {
	//freopen("in.txt", "r", stdin);
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	int ans = min(a*n, b);
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt[10][200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    while(cin>>n>>m)
    {
        priority_queue<ll> pq;
        for(int i=0;i<n;i++)
        {
            ll x;
            cin>>x;
            pq.push(x);
        }
        for(int i=0;i<m;i++)
        {
            ll x=pq.top();
            pq.pop();
            ll y=x/2LL;
            //if(x%2) y++;
            pq.push(y);
        }
        ll ans=0;
        while(pq.size()>0)
        {
            ans += pq.top();
            pq.pop();
        }
        cout<<ans<<endl;




    }
    return 0;
}


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

template <typename _Tp> inline void read(_Tp&x){
	char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
	while(isdigit(c11))x=x*10+c11-'0',c11=getchar();
}

const ll MX=1e10;
const int N=101000,M=2400;
ll a[N],bs[N];
int is[M],pri[M];
int n,ans,tot,tp;
bool t1=false;

map <ll,int> mp;

inline ll pw3(ll x){return x*x*x;}

inline ll f(ll x){
	ll res(1ll);
	for(int i=1;i<=tp&&pri[i]<=x;++i){
		int t=0;
		while(x%pri[i]==0)
			x/=pri[i],++t;
		if(t==1)res*=pri[i]*pri[i];
		else if(t==2)res*=pri[i];
	}
	if(x==1)return res;
	ll sqr=sqrt(x);
	if(sqr*sqr==x)return res*sqr;
	else if(res*x*x<=MX)return res*x*x;
	else return -1;
}

int main(){
	read(n);
	for(int i=1;i<=n;++i)read(a[i]);
	for(int i=2;i<=2200;++i){
		if(!is[i])pri[++tp]=i;
		for(int j=1;j<=tp&&i*pri[j]<=2200;++j){
			is[i*pri[j]]=1;
			if(i%pri[j]==0)break;
		}
	}
	for(int i=1;i<=tp&&pw3(pri[i])<=MX;++i)
		bs[++tot]=pw3(pri[i]);
	for(int i=1;i<=n;++i){
		for(int j=1;j<=tot&&bs[j]<=a[i];++j)
			while(a[i]%bs[j]==0)a[i]/=bs[j];
		if(a[i]==1)t1=true;
		else ++mp[a[i]];
	}
	sort(a+1,a+n+1);
	int i=1;
	while(a[i]==1&&i<=n)++i;
	for(int las;(las=i)<=n;++i){
		while(a[i]==a[i+1])++i;
		ll tar=f(a[i]);
		if(tar==-1)ans+=i-las+1;
		else if(tar<a[i]&&(*lower_bound(a+1,a+n+1,tar))==tar)continue;
		else ans+=max(i-las+1,mp[tar]);
	}
	printf("%d\n",ans+t1);
	return 0;
}

Measured memory_bytes: 11392
#include <iostream>
#include <vector>
#include <cmath>
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define debug freopen("input", "r", stdin);freopen("output", "w", stdout)
#define endl '\n'
#define all(var) var.begin(), var.end()
typedef unsigned long long ll;
ll const MOD = 1e9+7;
using namespace std;

int main(){
    int n; cin >> n;
    vector<int> v(n);
    int mx = 0, mn = MOD;
    for(auto &i: v){
        cin >> i;
        mx = max ( mx, i );
        mn = min ( mn, i );
    }
    int ans = MOD;
    for(int i = mn; i <= mx; i++){
        int sum = 0;
        for(auto it: v){
            sum += pow((it-i), 2);
        }
        ans = min ( ans, sum );
    }
    cout << ans << endl;
}




Measured memory_bytes: 256
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        sc.nextLine();
        Set<Integer> acList = new HashSet<>();
        Map<Integer, Integer> waMap = new HashMap<>();
        for (int i = 0; i < m; i++){
            int q = sc.nextInt();
            String r = sc.next();
            if(!acList.contains(q)) {
                if (r.equals("AC")) {
                    acList.add(q);
                } else {
                    waMap.put(q, waMap.getOrDefault(q, 0) + 1);
                }
            }
            sc.nextLine();
        }
        System.out.println(acList.size() + " " + acList.stream().mapToInt(q -> waMap.getOrDefault(q, 0)).sum());
    }
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> dp(3);
    for(int day=0;day<n;day++)
    {
        vector<int> new_dp(3);
        vector<int> c(3);
        for(int i=0;i<3;i++)cin >> c[i];

        for(int i=0;i<3;++i)
        {
            for(int j=0;j<3;j++)
            {
                if(i!=j)
                {
                    new_dp[j]=max(new_dp[j],dp[i]+c[i]);
                }
            }
        }

        dp = new_dp;
    }

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

Measured memory_bytes: 256
import collections
import itertools


Card = collections.namedtuple("Card", ("suit", "number"))
suit_rank = {"S": 0, "H": 1, "C": 2, "D": 3}


# すべてのカードを用意
ans = set()
for suit, number in itertools.product("SHCD", range(1, 14), repeat=1):
    ans.add(Card(suit, number))

n = int(input())
cards = {Card(suit, int(number)) for (suit, number) in [input().split() for _ in range(n)]}

ans.difference_update(cards)
ans = list(ans)
ans.sort(key=lambda x: x.number)
ans.sort(key=lambda x: suit_rank[x.suit])
for a in ans:
    print(a.suit, a.number)



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

int main(){
  int n; cin >> n;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  int ans = 0;
  for(int i = 1; i < n-1; i++){
    int a = max(p[i-1],p[i+1]);
    a = min(a,p[i]);
    if(a == p[i] && a > min(p[i-1],p[i+1])) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

string s;

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

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

using namespace std;

#define endl "\n"
#define lln long long int
#define IOS ios::sync_with_stdio(0);cin.tie(0);

const int MOD = 1e9 + 7;

int main(){
	IOS;

	int n;
	cin >> n;
	lln nine = 1, ten = 1,eig = 1;
	for(int i=0;i<n;i++){
		ten = (ten * 10) % MOD;
		nine = (nine * 9) % MOD;
		eig = (eig * 8) % MOD;
	}
	lln val = (ten -2*nine + eig + 2*MOD) % MOD;
	cout << val << endl;
	return 0;    
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define inv(x) power(x,Mod-2)
#define upd(a,b) a=add(a,b)
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
int add(int a,const int b){a+=b;if(a>=Mod)a-=Mod;return a;}
int sub(int a,const int b){a-=b;if(a<0)a+=Mod;return a;}
int mul(const int a,const int b){return (ll)a*b%Mod;}
int power(int x,int cs)
{
	int ras=1;
	while(cs)
	{
		if(cs&1) ras=mul(ras,x);
		x=mul(x,x);cs>>=1;
	}
	return ras;
}
const int N=2020;
int n,K,tot,ans=0;
int dp[N][N],sum[N],zp[N*N],fp[N*N];
int C(int a,int b)
{
	if(a<0||b<0||a<b) return 0;
	return mul(zp[a],mul(fp[b],fp[a-b]));
}
int main()
{
	int i,j;
	scanf("%d%d",&n,&K);
	if(K==1)
	{
		puts("1");
		return 0;
	}
	tot=n*K;
	zp[0]=fp[0]=1;
	for(i=1;i<=tot;i++) zp[i]=mul(zp[i-1],i);
	fp[tot]=inv(zp[tot]);
	for(i=tot-1;i>=1;i--) fp[i]=mul(fp[i+1],i+1);
	dp[1][0]=1;
	for(i=2;i<=n;i++)
	{
		memset(sum,0,sizeof(sum));
		for(j=0;j<=i;j++)
		{
			if(j>0) sum[j]=sum[j-1];
			upd(sum[j],dp[i-1][j]);
		}
		for(j=0;j<i;j++)
		{
			upd(dp[i][j],mul(sum[j],C(i*(K-1)+j-1,K-2)));
		}
	}
	for(i=0;i<=n;i++) upd(ans,dp[n][i]);
	ans=mul(ans,zp[n]);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 47872
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int x = sc.nextInt();

		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}

		int d = 0;
		int cnt = 1;
		for (int i = 0; i < n; i++) {
			d = d + l[i];
			if (d <= x) {
				cnt++;
			} else {
				break;
			}
		}

		pr.println(cnt);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

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

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N, K; cin >> N >> K;
	vi arr (N);
	F0R(i, N) cin >> arr[i];
	FOR(i, K, N) {
		print((arr[i] > arr[i-K]) ? "Yes" : "No");
	}
}

Measured memory_bytes: 3956
package main

import (
	"fmt"
	"math"
)

func main() {
	var s string
	var t string
	fmt.Scan(&s, &t)
	var cnt int
	for i := 0; i < 3; i++ {
		if s[i] == t[i] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var inf = int(1e9)

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

int f(int i) {
    return (i/2+1)/2*2-2+i%2;
}

void solve() {
    int N, K;
    cin >> N >> K;
    if (N % K  == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 256
//kyoupro
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main()
{
	int N,i;
	cin >> N;
	string S,T;
	cin >>S >>T;
	scanf("%s %s" ,S ,T);
	for(i=0;i<N;i++){
		cout<<S[i]<<T[i];
	}
	return 0;
}

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

#define _CRT_SECURE_NO_WARNINGS

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1; i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

const int INF = 1000000000;
const double PI = 3.1415926535897932384626433832795;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

using LL = long long int;
using LD = long double;
using pii = pair<int, int>;
using pdd = pair<double, double>;
using pll = pair<LL, LL>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<LL>;

//==============================================

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

	string s;
	cin >> s;

	int sSize = s.size();

	stack<char> sta;
	REP(i, sSize) {
		if (s[i] == '0' || s[i] == '1') {
			sta.push(s[i]);
		} else {
			if (!sta.empty()) {
				sta.pop();
			}
		}
	}

	string str = "";
	while(!sta.empty()) {
		str += sta.top();
		sta.pop();
	}

	reverse(ALL(str));
	cout << str << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int N=4e5+10;
struct Ed{int fr,to,w;}E[N];
int f[N],n,Q,fa[N],cc;
long long Ans;
int cmp(const Ed&A,const Ed&B) {return A.w<B.w;}
int find(int x) {return fa[x]==x?x:fa[x]=find(fa[x]);}
void Work()
{
	for(int i=0;i<=n-2;i++)
		f[i+1]=min(f[i+1],f[i]+2);
	f[0]=min(f[0],f[n-1]+2);
}
int main()
{
	cin>>n>>Q;
	memset(f,63,sizeof(f));
	for(int i=1;i<=Q;i++)
	{
		int x,y,w;scanf("%d%d%d",&x,&y,&w);
		E[i]=(Ed){x,y,w};
		f[x]=min(f[x],w+1);
		f[y]=min(f[y],w+2);
	}
	cc=Q;Work();Work();
	for(int i=0;i<=n-2;i++)
		E[++cc]=(Ed){i,i+1,f[i]};
	E[++cc]=(Ed){n-1,0,f[n-1]};
	sort(E+1,E+cc+1,cmp);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=cc;i++)
	{
		int fx=find(E[i].fr),fy=find(E[i].to);
		if(fx!=fy) Ans+=E[i].w,fa[fx]=fy;
	}
	cout<<Ans<<endl;
}


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

int main(void){
    int N,x;
    cin>>N>>x;
    vector<ll> a(N);
    for (int i=0;i<N;i++) cin>>a[i];
    ll ans=0;
    if (a[0]>x) {
        ans+=a[0]-x;
        a[0]=x;
    }
    for (int i=1;i<N;i++){
        if (a[i]+a[i-1]>x){
            ans+=a[i]+a[i-1]-x;
            a[i]=-a[i-1]+x;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024