akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_142
{
    class B
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nk = ReadInts();
            int n = nk[0];
            int k = nk[1];
            int[] hs = ReadInts();
            WriteLine(hs.Count(a => a >= k));
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 17632
open Printf
open Scanf

let () =
  let sd = scanf "%s " (fun x -> x) in
  let t = scanf "%s " (fun x -> x) in
  let sdl = String.length sd in
  let tl = String.length t in
  let mts i =
    let rec loop j =
      if j = tl then true
      else if sd.[i+j] = '?' || t.[j] = sd.[i+j] then loop (j + 1)
      else false in
    loop 0 in
  let rec loop i =
    if i < 0 then "UNRESTORABLE"
    else if mts i then let s1 = String.concat "" [String.sub sd 0 i ; t ; String.sub sd (i + tl) (sdl - i - tl)] in
                       String.init sdl (fun j -> if s1.[j] = '?' then 'a' else s1.[j])
    else loop (i - 1) in
  loop (sdl - tl) |> printf "%s\n"


Measured memory_bytes: 2432
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

int main() {
	IOS;
	ll a, b, x;
	cin >> a >> b >> x;
	ll ans = b / x - max((ll)0,(a - 1) / x);
	if (a == 0) ans++;
	cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int, int>;

int a[12][12];

const int INF = 1001001001;
int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int>c(n);
	rep(i, n) {
		cin >> c[i];
		rep(j, m)cin >> a[i][j];
	}

	int ans = INF;

	rep(s, 1 << n) {
		int cost = 0;
		vector<int>d(m);
		rep(i, n) {
			if (s >> i & 1) {
				cost += c[i];
				rep(j, m)d[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(j, m)if (d[j] < x)ok = false;
		if (ok)ans = min(ans, cost);
	}
	if (ans == INF)cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3160
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    rep(i, N) cin >> x.at(i) >> u.at(i);

    double ans;
    rep(i, N) {
        if (u.at(i) == "JPY") {
            ans += x.at(i);
        } else {
            ans += x.at(i) * 380000.0;
        }
    }

    cout << fixed << setprecision(8) << ans << endl;

    return 0;
}


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

int main()
{
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  valarray<int> xs(n + 1), ys(m + 1);
  for (int i = 0; i < n; i++) cin >> xs[i];
  for (int i = 0; i < m; i++) cin >> ys[i];
  xs[n] = x;
  ys[m] = y;
  cout << (xs.max() < ys.min() ? "No War" : "War") << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int main(void) {
    int n;
    int x;
    scanf("%d", &n);
    for (int i=3; i<=n; i++) {
        if (i%3==0){
        printf(" ");
        printf("%d", i);
        }else{
            x = i;
            while (x>=3){
                if(x%10==3){
               
                    printf(" ");
                    printf("%d", i);
                    break;
                 }
                x = x/10;
            }
        }
    }
    printf("\n");
}



Measured memory_bytes: 2708
from typing import List


def main():
    X, N = map(int, input().split())

    if N == 0:
        print(X)
        exit()

    p_lst: List[int] = list(map(int, input().split()))

    for i in range(51):
        if X - i not in p_lst:
            print(X - i)
            exit()
        if X + i not in p_lst:
            print(X + i)
            exit()


if __name__ == "__main__":
    main()


Measured memory_bytes: 10272
#include<bits/stdc++.h>
 
using namespace std;
#define int long long
#define N 666666
int sum[N];
signed  main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='g') sum[i]=sum[i-1]+1;
		else sum[i]=sum[i-1]-1;
	}
	//cout<<sum[s.size()-1]<<'\n';
	if(sum[s.size()-1]>0) cout<<sum[s.size()-1]/2;
	else cout<<sum[s.size()-1];
    return 0;
}
/*


ggppgggpgg

ggppgpgpgp

*/

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

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

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

const double PI  = 3.141592653589793238463;
const int MOD = 1000000007;
const Int INF = numeric_limits<Int>::max() / 3;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec){
        is >> x;
    }
    return is;
}

template<typename T>
string join(const vector<T>& vec, string sep = " "){
    stringstream ss;
    for(int i = 0; i < vec.size(); i++){
        ss << vec[i] << (i + 1 == vec.size() ? "" : sep);
    }
    return ss.str();
}

int solve(int n, int a, int b){
    return min(a * n, b);
}

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

    int n, a, b;
    cin >> n >> a >> b;

    cout << solve(n, a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
#define MAXN 100
#define INFTY (1 << 21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[MAXN][MAXN];

int prim()
{
	int d[MAXN], p[MAXN], color[MAXN];
	int u, minv;
	for(int i = 0; i < n; i++)
	{
		d[i] = INFTY;
		p[i] = -1;
		color[i] = WHITE;
		//printf("===\n");
	}
	d[0] = 0;
	while(true)
	{
		u = -1;
		minv = INFTY;
		for(int i = 0; i < n; i++)
		{
			if(color[i] != BLACK && d[i] < minv)
			{
				u = i;
				minv = d[i];
				//printf("%d \n", u);
			}
		}
		if(u == -1)
		{
			break;
		}
		color[u] = BLACK;
		for(int v = 0; v < n; v++)
		{
			if(color[v] != BLACK && M[u][v] != INFTY)
			{
				if(d[v] > M[u][v])
				{
					d[v] = M[u][v];
					p[v] = u;
					color[v] = GRAY;
				}
			}
		}
	}
	int sum = 0;
	for(int i = 0; i < n; i++)
	{
		if(p[i] != -1)
		{
			sum += M[i][p[i]];
		}
	}
	return sum;
}

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			int e;
			scanf("%d", &e);
			M[i][j] = (e == -1) ? INFTY : e;
		}
	}
	printf("%d\n", prim());
	return 0;
}



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


int main(){
	string s,s2;
	cin >> s >> s2;
	for(int i=0;i<s.size();i++){
		cout << s[i];
		if(s2.size()<=i)continue;
		cout << s2[i];
	}
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
#define dbg(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#define dpri(x) dbg(#x ": %d\n", x)
#define dprs(x) dbg(#x ": %s\n", x)
#include <stdio.h>
#include <math.h>
typedef long long ll;
const int MYINF = 1e9+7;
const double EPS = 1e-6;

typedef struct {
        double x;
        double y;
} V;

V vector_sub(V *a, V *b) {
        V c;
        c.x = a->x - b->x;
        c.y = a->y - b->y;
        return c;
}

double vector_abs(V *a) {
        return sqrt(a->x*a->x + a->y*a->y);
}

double a, b, c, rad;

int main(int argc, char **argv)
{
        scanf("%lf %lf %lf", &a, &b, &c);
        V va, vb, vc;

        rad = c * M_PI / 180.0;
        va.x = a;
        va.y = 0;
        vb.x = b * cos(rad);
        vb.y = b * sin(rad);
        vc = vector_sub(&va, &vb);

        printf("%f\n", va.x * vb.y / 2.0);
        printf("%f\n", a + b + vector_abs(&vc));
        printf("%f\n", vb.y);
        return 0;
}

Measured memory_bytes: 648
K,A,B=map(int,input().split())
if(A>=B-1 or K<A-1):
    print(K+1)
    exit()
res=K-A+1
if(res%2==0):
    print((B*(res//2))-(A*((res//2)-1)))
else:
    print((B*(res//2))-(A*((res//2)-1))+1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80  
using namespace std;                     //                       10333 ~2^13.33
using ll=long long;                      // seq 1 128 | factor   100333 ~2^16.61
using vl=vector<ll>;                     //   | grep -v ' .* '  1300111 ~2^20.31
using vvl=vector<vl>;                    //                    10300777 ~2^23.30
using vb=vector<bool>;                   //                   100400999 ~2^26.58
using vs=vector<string>;                 //                  1300400999 ~2^30.28
using pll=pair<ll,ll>;                   //                 10200500333 ~2^33.25
const ll oo =0x3f3f3f3f3f3f3f3fLL;       //                100200400777 ~2^36.54
const double eps=1e-9;                   //               1200300700111 ~2^40.13
#define sz(c) ll((c).size())             //              10200300500777 ~2^43.21
#define all(c) begin(c),end(c)           //             100200300400777 ~2^46.51
#define mp make_pair                     //            1200300400600999 ~2^50.09
#define mt make_tuple                    //           10200300400600111 ~2^53.18
#define pb push_back                     //          100200300400600333 ~2^56.48
#define eb emplace_back                  //         1200300400500800999 ~2^60.06
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main() {
	cin.sync_with_stdio(0);

	ll mod = 1000000007;

	ll n;
	cin >> n;

	vl a(n);
	vl prefix(n);
	FOR(i,0,n) {
		cin >> a[i];
		if(i > 0)
			prefix[i] = prefix[i-1];
		prefix[i] += a[i];
		prefix[i] %= mod;
	}

	ll res = 0;
	FOR(i,1,n) {
		res += a[i] * prefix[i-1];
		res %= mod;
	}

	cout << res << endl;
}


Measured memory_bytes: 6344
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while(getline(ss,x,c)) v.emplace_back(x); return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
const ll MOD=1e9+7;
vector<int> primes,prime;
class PRPRPR{
public:
  PRPRPR(int PRIME_MAX){
    prime.resize(PRIME_MAX);
    for(int i=2;i<PRIME_MAX;i++)if(!prime[i]){
	primes.pb(i);
	for(int j=i*2;j<PRIME_MAX;j+=i)
	  prime[j]=1;
      }
  }
} prprprpr(11234);

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int n;
  cin>>n;
  ll re=1;
  for(int p:primes){
    int sum=0;
    for(ll i=p;i<=n;i*=p) sum+=n/i;
    (re*=sum+1)%=MOD;
  }
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    const n = lines[0].split("S");
    let max = Math.max(...n.map(v=>v.length));
    console.log(max)
    
    
});

check = (a)=>{
    return a.toString()===a.toString().split("").reverse().join("")?1:0;
}


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

int main(){
    long long int n;
    cin >> n;
    long long int lim1 = min((long long int)sqrtl(n)+2LL, n);
    vector<bool> is_prime(lim1+1, true);
    for(long long int i = 2; i <= lim1; i++){
        if(is_prime[i]){
            for(int j = i * 2; j <= lim1; j += i){
                is_prime[j] = false;
            }
        }
    }
    vector<long long int> prime;
    for(long long int i = 2; i <= lim1; i++){
        if(is_prime[i]) prime.push_back(i);
    }

    long long int n1 = n;
    long long int ans = 0;
    for(long long int i = 0; i < prime.size(); i++){
        long long int z = prime.at(i);
        for(long long int j = 1; ; j++){
            if(n1 >= z && n1 % z == 0){
                ans++;
                n1 /= z;
            }else{
                break;
            }
            z *= prime.at(i);
        }
        while(n1 % prime[i] == 0) n1 /= prime[i];
    }

    if(n1 > 1){
        bool isprime = true;
        for(long long int i = 2; i <= min((long long int)sqrtl(n1)+2LL, n1); i++){
            if(n1 % i == 0) isprime = false;
        }
        if(isprime) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4504
import math
n,k = map(int,input().split())
l = list(map(int,input().split()))
if max(l) < k:
    print("IMPOSSIBLE")
    exit()

x = l[0]
for i in l:
    x = math.gcd(x,i)

if x == 1:
    print("POSSIBLE")
else:
    for i in l:
        if (k-i)%x == 0:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")



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

int main() {
	int n, m;
	while(cin >> m >> n, m || n) {
		vector<int> nex;

		nex.resize(m);
		for(int i = 0; i < m; i++) nex[i] = (i+1) % m;
		int pre = nex.size()-1;
		int p = 0;
		int cnt = nex.size();
		for(int t = 1; t <= n; t++) {
			string str;
			cin >> str;
			if(cnt == 1) continue;
			bool flg = false;
			int num = 0;
			flg = (str == "Fizz") || (str == "Buzz") || (str == "FizzBuzz");
			if(!flg) {
				flg = true;
				for(int i = 0; i < str.size(); i++) {
					num *= 10;
					num += str[i] - '0';
					flg &= '0' <= str[i] && str[i] <= '9';
				}
			}

			if(flg) {
				if(t%15==0)
					flg = str == "FizzBuzz";
				else if(t%3==0)
					flg = str == "Fizz";
				else if(t%5==0)
					flg = str == "Buzz";
				else
					flg = num == t;

			}

			if(flg) {
				pre = p;
				p = nex[p];
			}
			else {
				nex[pre] = nex[p];
				int tmp = p;
				p = nex[p];
				nex[tmp] = -1;
				cnt--;
			}
		}

		bool f = false;
		for(int i = 0; i < nex.size(); i++) {
			if(nex[i]+1) {
				if(f) cout << " ";
				f = true;
				cout << i+1;
			}
		}
		cout << endl;
	}
}

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


div = make_divisors(N)

score = 0
for i in div:
    if N // i - 1 > i:
        score += N // i - 1


print(score)

Measured memory_bytes: 38896
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        List<int> values = new List<int>(Console.ReadLine().Split(' ').Select(s => int.Parse(s)));
        //List<int> values = new List<int>();

        //string input = Console.ReadLine();
        //int n = int.Parse(input.Split(' ')[0]);
        //int m = int.Parse(input.Split(' ')[1]);
        //int k = int.Parse(input.Split(' ')[2]);

        values.Remove(1);
        values.Remove(9);
        values.Remove(7);
        values.Remove(4);

        if(values.Count==0)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

Measured memory_bytes: 13152
A, B, K = list(map(int, input().split()))
if 2 * K >= B - A + 1:
	for i in range(A, B + 1):
		print(i)
else:
	for i in range(A, A + K):
		print(i)

	for i in range(B - K + 1, B + 1):
		print(i)

Measured memory_bytes: 3060
N = int(input())
time = [0]*100009
x = [0]*100009
y = [0]*100009
for i in range(N):
    time[i+1],x[i+1],y[i+1] = [int(x) for x in input().split()]

flag = True
for i in range(N):
    dt = time[i+1]-time[i]
    dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i])
    if dt < dist:
        flag = False
    if dt % 2 != dist % 2:
        flag = False
if flag:
    print('Yes')
else:
    print('No')


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

long long  N,D;
struct Node{
	long long  x,y;
}A[1000010];
bool cmp(Node a,Node b)
{
	return a.x*a.x +a.y*a.y > b.x*b.x+b.y*b.y;
}
int main()
{
	cin>>N>>D;
	int dd=0;
	for(int i =1;i <= N;i++)
	{
		cin>>A[i].x>>A[i].y;
		if(A[i].x*A[i].x+A[i].y*A[i].y*1LL <= D*D)
		dd++;
	}
	cout<<dd<<endl;
	return 0;
}

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

const int mod = 7 + (1e+9);

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
};

int main(){
  int n,m; cin >> n >> m;
  deque<int> s(n),t(m);
  for(auto&e:s)cin >> e;
  for(auto&e:t)cin >> e;
  s.push_front(0);
  t.push_front(0);
  modint<mod> dp[2010][2010] = {};
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      modint<mod> x = (s[i]==t[j]?dp[i-1][j-1]+1:0);
      dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1] + x;      
    }
  }
  cout << dp[n][m]+1 << endl;
  return 0;
}


Measured memory_bytes: 32000
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

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


int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	string s; cin >> s;
	bool flag = true;
	ll res = 0;
	int now = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			now++;
			if (now == 4) {
				//cout << i << endl;
				if (flag) res++;
				else flag = true;
				now = 0;
			}
		}
		else {
			now--;
			if (now == 0) flag = true;
			if (now < 0) {
				flag = false;
				now = 3;
			}
		}
	}
	cout << res << endl;
	return 0;

}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string w;
int a[26];

int main() {
	cin >> w;
	rep(i,w.length()) a[w[i]-'a']++;
	rep(i,26) {
		if (a[i]%2!=0) {
			cout << "No" << ln;
			return 0;
		}
	}
	cout << "Yes" << ln;
}

Measured memory_bytes: 256
N,L = map(int,input().split())

taste = 0
taste_sum = 0
eat = 0
temp_eat = 0

for i in range(1,N+1):
  taste = L+i-1
  taste_sum += taste
  
  if i == 1:
    eat = taste
    temp_eat = abs(taste)
    
  elif abs(taste) < temp_eat:
    temp_eat = abs(taste)
    eat = taste

print(taste_sum - eat)

Measured memory_bytes: 3064
from sys import stdin
from collections import deque
from copy import deepcopy


class State:
    def dup(self):
        ns = State()
        ns.b = self.b[:]
        ns.z = self.z
        ns.c = self.c
        return ns


def read_board():
    s = State()
    s.b = [int(x) for x in stdin.read().split()]
    s.z = s.b.index(0)
    s.c = 0
    return s


def move_zero(s, h):
    ns = s.dup()
    ns.z += h
    ns.b[s.z], ns.b[ns.z] = ns.b[ns.z], ns.b[s.z]
    ns.c += 1
    return ns


def push_hands(q, s):
    if s.z % 3 != 0:
        q.append(move_zero(s, -1))
    if s.z % 3 != 3 - 1:
        q.append(move_zero(s, 1))
    if s.z // 3 != 0:
        q.append(move_zero(s, -3))
    if s.z // 3 != 3 - 1:
        q.append(move_zero(s, 3))


def solve(s):
    hist = set()
    q = deque([])
    while True:
        t = tuple(s.b)
        if t == (1, 2, 3, 4, 5, 6, 7, 8, 0):
            return s.c
        if t not in hist:
            push_hands(q, s)
            hist.add(t)
        s = q.popleft()


def main():
    b = read_board()
    print(solve(b))


main()



Measured memory_bytes: 56516
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lld double
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define vc vector
#define rep1(it,v) for(it=v.begin();it!=v.end();it++)
#define ayush ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define input(v) for(auto &it:v)cin>>it
#define inf 1000000007
#define pb push_back

lld v1[3005]; lld dp[3005][3005];

void fun(ll n)
{
    dp[0][0]=1; rep(i,1,n) dp[0][i]=0;
    rep(i,1,n) dp[i][0]=dp[i-1][0]*(1-v1[i-1]);
    rep(i,1,n)
    {
        rep(j,1,n)
        {
            dp[i][j]=dp[i-1][j-1]*v1[i-1]+dp[i-1][j]*(1-v1[i-1]);
        }
    }
    ll n1=(n/2)+1; lld ans1=0; cout<<setprecision(12);
    rep(i,n1,n) ans1+=dp[n][i];
    cout<<ans1<<endl;
}

int main()
{
    ll n; cin>>n; rep(i,0,n-1) cin>>v1[i];
    fun(n); 
    
    
}


Measured memory_bytes: 74192
n = int(input())
h = list(map(int, input().split()))
H = [h]
ans = 0
while len(H) > 0:
  for e in H:
    if len(e) == 0:
      H.remove(e)
    elif 0 in e:
      a = e[:e.index(0)]
      b = e[e.index(0) + 1:]
      H.append(a)
      H.append(b)
      H.remove(e)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    else:
      ans += min(e)
      c = [e[j] - min(e) for j in range(len(e))]
      a = c[:c.index(0)]
      b = c[c.index(0) + 1:]
      H.append(a)
      H.append(b)
      H.remove(e)
      if [] in H:
        H.remove([])
        if len(H) == 0:
          break
    if [] in H:
      H.remove([])
      if len(H) == 0:
        break
print(ans)

Measured memory_bytes: 9256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	var i int
	if sc.Scan() {
		if num, err := strconv.Atoi(sc.Text()); err == nil {
			i = num
		}
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var summerDay, m int = nextInt(), nextInt()
	var homeWorkAllCosts int
	for i := 0; i <= m; i++ {
		homeWorkAllCosts += nextInt()
	}
	if summerDay < homeWorkAllCosts {
		fmt.Println("-1")
		return
	} else {
		fmt.Println(summerDay - homeWorkAllCosts)
		return
	}
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define inf 0x3f3f3f3f
#define mod 1000000007
#define maxm 
#define maxn 

int main()
{
	int a, b;
	char s[20];
	
	scanf("%d%d%s", &a, &b, s);
	for (int i = 0; i < a; i++) {
		if (s[i] > '9' || s[i] < '0') {
			puts("No");
			return 0;
		}
	}
	if (s[a] != '-') {
		puts("No");
		return 0;
	}
	for (int i = a + 1; i < a + b + 1; i++) {
		if (s[i] > '9' || s[i] < '0') {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] d = new int[N];
		
		for(int i= 0; i < N ;i++) { 
			d[i] = sc.nextInt();
		}
		int sum = 0;
		for(int i =0; i < N-1 ; i++ ) {
			for(int j = 0; j < N; j++) {
				if(j==i) {
					continue;
				}else if(i>j){
					continue;
				}else {
					sum += d[i]*d[j];
				}
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '

const int INF = 1e9 + 5;

int main() {
	string s, t;
	cin >> s >> t;
	t.erase(t.end()-1);
	if(s == t){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}


    return 0;
} 


Measured memory_bytes: 3036
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
#define MOD 1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N,a;cin>>N;
  set<int> S;
  REP(i,0,N){
    cin>>a;
    if(S.count(a)>0){
      S.erase(a);
    }
    else{
      S.insert(a);
    }
  }
  int ans=0;
  each(s,S){
    ans++;
  }
  print(ans)

}


Measured memory_bytes: 4992
#include<stdio.h>
#include<algorithm>
using namespace std;


int main()
{
    int a[4], sum=99999;
    scanf("%d%d%d",a+1,a+2,a+3);
    int i, j, k;
    for(i=1;i<=3;i++)
        for(j=1;j<=3;j++)
        for(k=1;k<=3;k++)
    {
        if(i==j||j==k||i==k) continue;
        sum=min(sum,abs(a[j]-a[i])+abs(a[k]-a[j]));
    }

    printf("%d",sum);
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define maxn 100005
#define ll long long 
using namespace std;

int n,m,i,j,k,a[maxn],b[maxn],c[maxn],id[maxn];
int em,e[maxn*2],nx[maxn*2],ls[maxn];
int cmp(int i,int j){return c[i]<c[j];}

void insert(int x,int y){
	em++; e[em]=y; nx[em]=ls[x]; ls[x]=em;
	em++; e[em]=x; nx[em]=ls[y]; ls[y]=em;
}

int fa[maxn]; ll g[maxn],f[maxn];
int father(int x){return (fa[x]==x)?x:fa[x]=father(fa[x]);}

int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]),c[i]=a[i]-b[i];
	for(i=1;i<=m;i++) scanf("%d%d",&j,&k),insert(j,k);
	for(i=1;i<=n;i++) id[i]=i;sort(id+1,id+1+n,cmp);
	for(int now=1;now<=n;now++){int x=id[now];
		fa[x]=x,f[x]=max(0,c[x]),g[x]=b[x];
		for(i=ls[x];i;i=nx[i]) if (fa[e[i]]){int y=e[i];
			if (father(x)!=father(y)){
				y=fa[y];
				f[x]=min(f[x],max(f[y],c[x]-g[y]));
				g[x]+=g[y],fa[y]=x;
			}
		}
	}
	printf("%lld\n",f[father(1)]+g[father(1)]);
}

Measured memory_bytes: 7188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<int,int> tp;
struct qq
{
    ll l, r;
    ll id;
}D[100005];
ll n;
ll ans[1000005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <complex>
#include <map>

using namespace std;

const int MAX_V = 1001;
// d[u][v]Íu©çvÖÌRXgBßÉ×Ú·éGbWÌRXgðüêÄ¨¢½è·êÎæ¢Í¸B
double d[MAX_V][MAX_V];
const int INF=1000000000;
// ¸_
int V;

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)

// prv[i][j] -> iªX^[gn_ÌÆ«Aj©çÇ±Éßé©
int prv[MAX_V][MAX_V];

// S_ÎÅZoHâèðÆ­O(V^3)AÓª ÁÄà®ì
void warshall_floyd(){
    for(int i = 0; i < V; i++){
        for(int j = 0; j < V; j++){
            for(int k = 0; k < V; k++){
                //d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
                if(d[j][k]>d[j][i]+d[i][k]){
                    int cp=k;
                    // XV
                    while(1){
                        prv[j][cp]=prv[i][cp];
                        cp=prv[i][cp];
                        if(cp==i)break;
                    }
                    d[j][k]=d[j][i]+d[i][k];
                }
            }
        }
    }
}
typedef complex<double> P;

void init(int n){
    V=n;
    for(int i = 0; i < MAX_V; i++){
        for(int j = 0; j < MAX_V; j++){
            if(i==j)d[i][j]=0;
            else d[i][j]=INF;
            prv[i][j]=INF;
        }
    }
}

int main(){
    int n;
    while(cin>>n&&n!=0){
        map<int,int> idxs;
        init(n);
        int billNum[MAX_V];
        P billP[MAX_V];
        for(int i=0;i<n;i++){
            int x,y;
            cin>>billNum[i]>>x>>y;
            billP[i]=P(x,y);
            idxs[billNum[i]]=i;
        }
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                double dist=abs(billP[i]-billP[j]);
                // £ª50ÈºÈç¹ðìéÆ¯ÉAßèûðüêÄ¨­
                if(dist<50||EQ(dist,50)){
                    d[i][j]=dist;
                    prv[i][j]=i;
                }
            }
        }
        warshall_floyd();
        int m;
        cin>>m;
        for(int i=0;i<m;i++){
            int s,g;
            cin>>s>>g;
            s=idxs[s];
            g=idxs[g];
            if(EQ(d[s][g],INF))
                cout<<"NA"<<endl;
            else{
                vector<int> v;
                int cp=g;
                while(1){
                    v.push_back(cp);
                    if(cp==s)
                        break;
                    cp=prv[s][cp];
                }
                for(int j = v.size()-1; j >= 0; j--){
                    cout<<billNum[v[j]];
                    if(j==0)cout<<endl;
                    else cout<<" ";
                }
            }
        }
    }

  return 0;
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

int n;
string s;
bool ok(string s) {
    if (s[0] != 'A') return false;
    if (count(s.begin()+2, s.end()-1,'C') != 1) return false;
    for (auto &c:s) {
        if (c != 'A' && c != 'C' && isupper(c)) return false;
    }
    return true;
}
signed main() {
    cin >> s;
    cout << (ok(s)? "AC":"WA") << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const double INF = 1001001001;

int main() {
	string s;
	cin >> s;
	int n = s.size();
	string t = s.substr(2, n - 3);
	string ans = "AC";
	//sの先頭の文字が大文字Aか？
	if (s[0] != 'A') ans = "WA";
	//tの中にCがちょうど一つ含まれるか？
	int m = t.size();
	int cnt = 0;
	rep(i, m) {
		if (t[i] == 'C') cnt++;
	}
	if (cnt != 1) ans = "WA";
	//Sのなかに大文字がふたつだけ含まれるか？
	int cnt2 = 0;
	rep(i, n) {
		if (isupper(s[i])) cnt2++;
	}
	if (cnt2 != 2) ans = "WA";
	
	cout << ans << endl;
	return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int A, B;
    cin >> A >> B;
    cout << max (A + B, max (A - B, A * B)) << endl;
    return 0;
}

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

int main() {
int N;
cin>>N;
  
   vector<double> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
 sort(vec.begin(), vec.end()); 
  
 double A=(vec.at(0)+vec.at(1))/2;
       
 for(int i=1;i<N-1;i++)
 {A=(A+vec.at(i+1))/2;
 }
  
  cout<<A<<endl;
   
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int main(){
  int a,b,t;
  cin>>a>>b>>t;
  cout<<b*(t/a)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <unordered_set>

using namespace std;

typedef long long i64;
typedef i64 int_t;
typedef vector<int_t> vi;
typedef vector<vi> vvi;

typedef pair<int_t, int_t> pi;

#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)

int main(int argc, char *argv[]) {
  i64 N;
  cin >> N;
  getchar();
  string S;
  getline(cin, S);

  unordered_set<i64> numbers;
  set<pi> pairs;
  set<pair<pi,i64>> triplets;
  i64 i;
  REP(0, N, i) {
    for(auto p: pairs) {
      triplets.insert(pair<pi,i64>(p, S[i]));
    }

    for(auto n: numbers) {
      pairs.insert(pi(n,S[i]));
    }

    numbers.insert(S[i]);
  }

  cout << triplets.size() << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fr front()
#define tp top()
typedef long long int ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
#define iofast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define iofile freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
const ll LLINF = 1e18;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 100005;

int main (){
	
	int a, b, c;
	
	scanf("%d/%d/%d", &a, &b, &c);
	a++;
	printf("%.4d/%.2d/%.2d\n", a, b, c);
	
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int n = nextInt();
			int r = nextInt();

			if (n == 0) {
				break;
			}

			int[] stone = new int[n];
			int position = 0;
			int can = r;
			while (true) {
				if (can == 0) {
					can = stone[position];
					stone[position] = 0;
				} else {
					can--;
					stone[position]++;
				}

				if (stone[position] == r) {
					break;
				}

				position++;
				if (position == n) {
					position = 0;
				}
			}
			System.out.println(position);

		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 17428
#include <iostream>
#include <vector>
#include <cstring>

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

using namespace std;

class Dice {
private:
    vector<int> num, i_num;

public:
    enum FACE {TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM}; 
    enum MOVE {TOP_TO_FRONT, TOP_TO_RIGHT, TOP_TO_LEFT, TOP_TO_BACK, FRONT_TO_LEFT, FRONT_TO_RIGHT};

    const int tb[6][4] = {
        {FRONT, TOP, BACK, BOTTOM},
        {RIGHT, TOP, LEFT, BOTTOM},
        {LEFT, TOP, RIGHT, BOTTOM},
        {BACK, TOP, FRONT, BOTTOM},
        {LEFT, FRONT, RIGHT, BACK},
        {RIGHT, FRONT, LEFT, BACK}
    };

    Dice() 
    { 
        num.assign(6, -1);
        i_num.resize(6);
        i_num = {1, 3, 5, 2, 4, 6};
    }

    Dice(int t, int f) 
    {
        num.resize(6), i_num.resize(6);
        i_num = {1, 3, 5, 2, 4, 6};
        roll(t, f);
    }

    void set_identity(vector<int> i) { num = i_num = i; }

    int top() {return num[TOP];}
    int bottom() {return num[BOTTOM];}
    int right() {return num[RIGHT];}
    int left() {return num[LEFT];}
    int front() {return num[FRONT];}
    int back() {return num[BACK];}
    int get(FACE f) { return num[f]; }

    void rotate(int move)
    {
        int tmp = num[tb[move][0]];
        rep(i, 3) num[tb[move][i]] = num[tb[move][i+1]];
        num[tb[move][3]] = tmp;
    }
    
    void roll(int t, int f)
    {
        num = i_num;

        for (int j=0; j<6; j++) {
            for (int i=0; i<4; i++) {
                if (num[0] == t && num[1] == f) return;
                rotate(FRONT_TO_RIGHT);
            }
            if (j%2) rotate(TOP_TO_FRONT);
            else rotate(TOP_TO_RIGHT);
        }
    }

    void print()
    {
        cerr << "[" << num[0] << ", " << num[FRONT] << ", " 
            << num[RIGHT] << "]" << endl;
    };

    bool operator == (const Dice &other) { return num == other.num; }
};

int main()
{
    Dice d1, d2;

    vector<int> num(6);
    rep(i, 6) cin >> num[i];
    d1.set_identity(num);
    rep(i, 6) cin >> num[i];
    d2.set_identity(num);

    bool ans = false;
    for (int i=0; i<100; i++) {
        for (int j=0; j<4; j++) {
            d1.rotate(d1.FRONT_TO_RIGHT);
            ans |= (d1 == d2);
        }
        if (i%2) d1.rotate(d1.TOP_TO_RIGHT);
        else d1.rotate(d1.TOP_TO_FRONT);
        ans |= (d1 == d2);
    }
    cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3156
n=int(input())
a=list(map(int, input().split()))

len=sum(a)
len_l=0
for i in range(n):
    if len/2>len_l:
        len_l+=a[i]
    else:
        center=i-1
        break
else:
    center=n-1
    
len_r=len-len_l
len_l-=a[center]
#半分との差
d=len/2-max(len_r,len_l)

print(int(d*2))

Measured memory_bytes: 26396
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<iostream>
#include<queue>
#include<map>
#include<set>
#include<complex>
#include<stack>
#include<cmath>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

#define X real()
#define Y imag()
typedef complex<double> P;

/*
namespace std{
	bool operator<(const P &a, const P &b){return a.X==b.X ? a.Y<b.Y : a.X<b.X;}
}*/
namespace std{
    bool operator<(const P &a, const P &b){
        return real(a)!=real(b)?real(a)<real(b):imag(a)<imag(b);
    }
}

double cross(P a,P b){return a.X*b.Y-b.X*a.Y;}
bool ccw(P a,P b,P c){return cross(b-a,c-a)>=0;}
vector<P> convex_VP(vector<P> ps) {
    int n = ps.size(), k = 0;
     
    if (n <= 1) return ps;
     
    sort(ps.begin(),ps.end());
    vector<P> qs(n * 2);
    for (int i = 0; i < n; qs[k++] = ps[i++]) {
        while (k > 1 && !ccw(qs[k-2],qs[k-1],ps[i])) k--;
    }
    for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--]) {
        while (k > t && !ccw(qs[k-2],qs[k-1],ps[i])) k--;
    }
     
    vector<P> res(qs.begin(), qs.begin() + k - 1);
    return res;
}
int main(){
	
	while(1){
		int n;
		cin>>n;
		if(n==0)break;
		
		vector<P> p;
		rep(i,n){
			double a,b;
			scanf("%lf,%lf",&a,&b);
			p.push_back(P(a,b));
		}
		
		vector<P> convex = convex_VP(p);
		/*
		rep(i,convex.size()){
			printf("%lf %lf\n",convex[i].X,convex[i].Y);
		}*/
		cout<<(int)p.size()-(int)convex.size()<<endl;
	}
}

Measured memory_bytes: 1280
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	var ans int
	if a == b {
		ans = c
	} else if b == c {
		ans = a
	} else {
		ans = b
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
# 0032
n1 = n2 = 0
while True:
    try:
        a, b, c = map(int, input().split(','))
        if a**2 + b**2 == c**2:
            n1 += 1
        elif a == b:
            n2 += 1
    except EOFError: break
print(n1)
print(n2)

Measured memory_bytes: 7612
words = input()

if len(words)%2 == 0:
    slice_cnt = len(words)//2
    words_cut = [words[:slice_cnt], words[slice_cnt:][::-1]]
    
    set_list = list(map(len, [set([words_cut[0][i], words_cut[1][i]]) for i in range(slice_cnt)]))
    print(set_list.count(2))
    
else:
    slice_cnt = (len(words) -1)//2
    words_cut = [words[:slice_cnt], words[slice_cnt+1:][::-1]]
    
    set_list = list(map(len, [set([words_cut[0][i], words_cut[1][i]]) for i in range(slice_cnt)]))
    print(set_list.count(2))

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	string s;
	cin >> n;
	cin >> s;
    int cnt=0;
	rep(i, n) {
		//黒の場所
		if (s[i] == '#') cnt++;
	}
	int ans = 1000000;
	int Lw = 0, Lb = 0;
	rep(i, n) {
		if (s[i] == '.') Lw++;
		else {
			int ansi = 0;
			ansi += Lb;
			ansi += (n - cnt) - Lw;
			ans = min(ans, ansi);
            Lb++;
		}
	}
    if(ans>cnt){
      cout<<cnt<<endl;
    }else{
      cout<<ans<<endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define repb(bit, n, init) for (ll bit = init; bit < (1 << n); ++bit)

int main()
{
    ll n, sum = 0,m=INF,M=-1 * INF,tmp;
    cin >> n;
    repi(i, n, 0)
    {
        cin >> tmp;
        sum += tmp;
        m = min(m,tmp);
        M = max(M,tmp);
    }

    cout << m << " " << M << " " << sum << endl;
    return 0;
}


Measured memory_bytes: 3104