akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

void _129() {
    int p, q, r;
    cin >> p >> q >> r;

    cout << min(p + q, min(q + r, p + r)) << endl;
}

void _128() {
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2 << endl;
}

void _127() {
    int a, b;
    cin >> a >> b;
    if (a >= 13)
        cout << b << endl;
    else if (a >= 6)
        cout << b / 2 << endl;
    else
        cout << 0 << endl;
}

void _126() {
    int n, k;
    string  s;

    cin >> n >> k;
    cin >> s;

    s[k - 1] = s[k - 1] + 32;
    cout << s << endl;
}

int main()
{
    _126();
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma gcc optimize("O3")
//#pragma gcc optimize("unroll-loops")
#ifdef EVAH
    #define _WIN32_WINNT 0x0500
    //#include<windows.h>
#endif
#define openFile(n) ShellExecute(nullptr,"open",n,nullptr,nullptr,SW_SHOWNORMAL);
#define closeP(n) system((string("taskkill /im ")+n+" /f").c_str());
#define closeConsole PostMessage(GetConsoleWindow(), WM_CLOSE, 0, 0);
#define opf "output.txt"
#define ipf "input.txt"
#define mem(n,x) memset(n,x,sizeof(n));
#define sf scanf
#define pf printf
#define ff first
#define ss second
#define pb push_back
#define PII pair<int,int>
#define For(x,n) for(int i=x; i<n; i++)
#define stv v+2*(mid-tl+1)
#define LL long long int
#define N 100001

LL dp[N],cost[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    #ifdef EVAH
        //freopen(ipf,"r",stdin);
        //openFile(ipf);
        //closeConsole;
        //freopen(opf,"w",stdout);
    #endif

    LL n,k;
    cin >> n >> k;
    For(0,n) {
        cin >> cost[i];
        dp[i] = 99999999999999999;
    }
    dp[0] = 0;
    For(1,n) {
        int j = 1;
        while(j<=k && i-j>=0) {
            dp[i] = min(dp[i],abs(cost[i]-cost[i-j])+dp[i-j]);
            j++;
        }
    }
    cout << dp[n-1] << "\n";

    #ifdef EVAH
        //openFile(opf);
        //Sleep(3000);
        //closeP("notepad.exe");
        //closeConsole;
    #endif
}


Measured memory_bytes: 5172
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto& e:c)
#define iter(it,c) for(auto it=c.begin(); it!=c.end(); ++it)

ll const inf = 1<<28;
double const pi = acos(-1);

int a[1024];
int d[1024*1024];

int solve(int n, int k){
    int c=0;
    rep(i,n)loop(j,i,n){
        int s=a[i]+a[j];
        if(s<=k){
            d[c++]=s;
        }
    }

    sort(d,d+c);
    int ans=0;
    rep(i,c){
        int s1=d[i];
        int lo=0, hi=c;
        while(lo+1<hi){
            int mid=(lo+hi)>>1;
            int s2=d[mid];
            if(s1+s2>k){
                hi=mid;
            }else{
                lo=mid;
            }
        }
        int s2=d[lo];
        ans=max(ans, s1+s2);
    }
    return ans;
}

int main(){
    int n,k;
    while(cin>>n>>k && n|k){
        a[0]=0;
        rep(i,n)cin>>a[i+1];
        n++;
        cout << solve(n,k) << endl;
    }
}

Measured memory_bytes: 3140
text = "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"

li = list(map(int, text.split(', ')))

k = int(input())

print(li[k - 1])


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U>
void chmax(T &a, U b) {
  if (a < b) a = b;
}

template <class T, class U>
void chmin(T &a, U b) {
  if (b < a) a = b;
}

template <class T>
T Sq(const T &t) {
  return t * t;
}

signed main() {
  int N = read(), tmp;
  FOR(i, 0, N / 4 + 1) {
    tmp = N - (i * 4);
    if (tmp % 7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  FOR(i, 0, N / 7 + 1) {
    tmp = N - (i * 7);
    if (tmp % 4 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main {
  public static void main(String[] args){
  Scanner scanner = new Scanner(System.in);
  int S = scanner.nextInt();
  int h = S / 3600;
  int m = S % 3600 / 60;
  int s = S - 3600 * h - 60 * m;
  System.out.println(h + ":" + m + ":" + s);
  }
}

Measured memory_bytes: 26116
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = (1..n).map { sc.next() }
    val b = (1..m).map { sc.next() }

    for (i in 0..(n - m)) {
        for (j in 0..(n - m)) {
            var isEq = true
            for (k in 0 until m) {
                if (a[i + k].substring(j, j + m) != b[k]) {
                    isEq = false
                    break
                }
            }
            if (isEq) {
                println("Yes")
                return
            }
        }
    }
    println("No")
}

Measured memory_bytes: 31268
// 1点更新、区間min取得 (RMQ)
// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_A

#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

const long long INF2 = (((ll)1<<31)-1);

template<class T> class SegTree   // 0-indexed
{
private:
    int n;             // 葉の数
    vector<T> data;    // ノードの値を持つ配列
    T def;                // 初期値かつ単位元
    
    T operation(T a, T b)    // 区間クエリで使う処理
    {
        return min(a, b);   // 区間minクエリ
    }

    T update(T a, T b)      // 点更新で使う処理
    {
        //return a+b;   // 加算の場合
        return b;       // 更新の場合
    }

    // 区間[a,b)の総和。ノードk=[l,r)に着目している。
    T _query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return def; // 交差しない
        if (a <= l && r <= b)
            return data[k]; // a,l,r,bの順で完全に含まれる
        else {
            T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // 左の子
            T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // 右の子
            return operation(c1, c2);
        }
    }
 
public:
    SegTree(int _n) {     // _n:必要サイズ
        def = INF2;        // 初期値かつ単位元
        n = 1;
        while (n < _n) n *= 2;
        data = vector<T>(2 * n - 1, def);
    }

    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }
 
    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};

int main(int argc, char* argv[])
{
    int n,q;
    scanf("%d%d", &n, &q);
    SegTree<long long> S(n);

    int i;
    for(i=0; i<q; i++) {
        int t,x,y;
        scanf("%d%d%d", &t, &x, &y);
        if(t==0) {
            S.change(x,y);
        }
        else {
            ll ans=S.query(x,y+1);
            printf("%lld\n", ans);
        }
    }

    return 0;
}


Measured memory_bytes: 6336
import heapq
import sys

input = sys.stdin.readline

def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d
################################
n=int(input()) #:頂点数　w:辺の数
w=n-1
edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y,z = map(int,input().split())
    edge[x-1].append([z,y-1])
    edge[y-1].append([z,x-1]) 

for i in dijkstra_heap(0,edge):
    if i%2==0:
        print(0)
    else:
        print(1)

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

namespace ConsoleApp15
{
    class Class48
    {
        static string[] s;
        static int h;
        static int w;
        static void Main()
        {
            var hw = Console.ReadLine().Split();
            h = int.Parse(hw[0]);
            w = int.Parse(hw[1]);
            s = new string[h];
            for(int i = 0; i < h; i++)
            {
                s[i] = Console.ReadLine();
            }

            bool ans = true;
            for(int i = 0; i < w; i++)
            {
                for(int j = 0; j < h; j++)
                {
                    if (s[j][i] == '#') ans =  check(i,j);
                    if (!ans) break;
                }
                if (!ans) break;
            }
            Console.WriteLine(ans ? "Yes" : "No");
        }
        static bool check(int x,int y)
        {
            bool a = false;
            for(int i = -1; i <= 1; i++)
            {
                if (i == 0) continue;
                if (0 <= y + i && y + i < h)
                    a |= s[y + i][x] == '#';
                if (0 <= x + i && x + i < w)
                    a |= s[y][x + i] == '#';
            }
            return a;
        }
    }
}


Measured memory_bytes: 13140
class RollingHash():
    def __init__(self,s):
        self.n=n=len(s)
        self.b=b=129
        self.M=M=2**61-1
        x,y=1,0
        self.f=f=[x]*(n+1)
        self.h=h=[y]*(n+1)
        for i,c in enumerate(s.encode()):
            f[i+1]=x=x*b%M
            h[i+1]=y=(y*b+c)%M
    def get(self,l,r):
        return(self.h[r]-self.h[l]*self.f[r-l])%self.M
def main():
    n=int(input())
    s=RollingHash(input())
    ok,ng=0,n
    while ng-ok>1:
        mid=ok+ng>>1
        d={}
        for i in range(0,n-mid+1):
            k=s.get(i,i+mid)
            if k in d:
                if d[k]+mid<=i:
                    ok=mid
                    break
            else:
                d[k]=i
        else:
            ng=mid
    print(ok)
main()

Measured memory_bytes: 4208
#include <iostream>
#include <vector>

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

using namespace std;

int main() {
	int W, H, T;
	cin >> W >> H >> T;

	int p;
	cin >> p;

	vector<int> x(p), y(p), t(p);
	rep(i, p) {
		cin >> x[i] >> y[i] >> t[i];
	}

	vector< vector<int> > s(H, vector<int>(W));
	rep(i, H) {
		rep(j, W) {
			cin >> s[i][j];
		}
	}

	vector< vector<int> > cnt(H, vector<int>(W));
	rep(i, p) {
		if(t[i] <= T) {
			if(s[y[i]][x[i]]) {
				cnt[y[i]][x[i]]++;
			}
		}
	}

	int ans = 0;
	rep(i, H) {
		rep(j, W) {
			ans += cnt[i][j];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
int main ()
{
    int N , A , rslt1  ;

    scanf("%d%d", &N , &A) ;

    rslt1 = N%500 ;
    if (rslt1<=A){
        printf("Yes\n") ;
    }

    else
    {
        printf("No\n") ;
    }

    return 0 ;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void){
  int c,i;
  char s[10000];
  while(1){
    fgets(s,10000,stdin);
    s[strlen(s)-1]=0;
    if(strcmp(s,"END OF INPUT")==0)
      break;
    c=0;
    for(i=0;s[i];i++){
      if(s[i]==' '){
	printf("%d",c);
	c=0;
      }
      else
	c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 524
#include <stdio.h>

int main(void)
{
  int i;
  int n = 0;
  char S[4];
  scanf("%s", S);
  for(i = 0;i < 4;i++){
    if(S[i] == '+') n++;
    else n--;
  }
  printf("%d\n", n);
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

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

const int MAXP = 1005;
int dp[11][MAXP];

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int d, g;
	scanf("%d%d", &d, &g);
	g /= 100;

	vi p(d+1), c(d+1);
	for (int i = 1; i <= d; i++) {
		scanf("%d%d", &p[i], &c[i]);
		c[i] /= 100;
	}

	for (int i = 1; i <= d; i++) {
		for (int j = 1; j < MAXP; j++) {
			for (int k = 0; k <= min(j, p[i]); k++) {
				int tmp = dp[i-1][j-k] + k * i;
				if (k == p[i]) tmp += c[i];
				dp[i][j] = max(dp[i][j], tmp);
			}
		}
	}

	for (int i = 1; i < MAXP; i++) {
		if (dp[d][i] >= g) {
			printf("%d\n", i);
			return 0;
		}
	}
	assert(false);
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  ll x, y;
  cin >> x >> y;
  ll A[] = {1, 3, 5, 7, 8, 10, 12};
  ll B[] = {4, 6, 9, 11};
  ll C = 2;

  ll cnt = 0;
  for (auto i: A)
  {
    if (x == i || y == i)
    {
      cnt++;
    }
    if (cnt == 2)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cnt = 0;
  for (auto i: B)
  {
    if (x == i || y == i)
    {
      cnt++;
    }
    if (cnt == 2)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  if (x == C && y == C)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

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

#define ll long long
int main()
{
	ll n; cin >> n;
	ll ans = 0;
	ans += 1000*(n/500);
	n%=500;
	ans += 5*(n/5);
	n%=5;

	cout << ans << '\n';
}


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

int main()
{
  int H, W;

  while( 1 ) {
    cin >> H >> W;
    if( H == 0 and W == 0 ) {
      break;
    }

    string buf1 = "";
    string buf2 = "";
    for( int i = 0; i < W; i++ ) {
      if( i % 2 == 0 ) {
        buf1 += "#";
        buf2 += ".";
      }
      else {
        buf1 += ".";
        buf2 += "#";
      }
    }

    for( int j = 0; j < H; j++ ) {
      if( j % 2 == 0 ) {
        cout << buf1 << endl;
      }
      else {
        cout << buf2 << endl;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b,c;
    cin >> a >> b >> c;
    if(a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    
    if(b > c) {
        int tmp = b;
        b = c;
        c = tmp;
    }
    
    if(a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    
    cout << a << " " << b << " " << c << endl;
}


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

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
	ll ans = N / (A+B) * A;
	ll r = N % (A+B);
	if (r>A){
		ans += A;
	}else{
		ans += r;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    for(int i=1;i<=3500;i++){
        for(int j=1;j<=3500;j++){
            ll x = (ll)N*i*j;
            ll y = (ll)4*i*j - N*i - N*j;
            if(y>0&&x%y==0){
                printf("%d %d %d\n", i, j, x/y);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
// マニ

#include<bits/stdc++.h>
#define ll            long long 
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)  for(ll int i=a;i<b;i++)
#define rrep(i,a,b) for(ll int i=a;i>=b;i--)
#define all(a)      (a).begin(),(a).end()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define PI 3.14159265358979323846
#define tr(i, cont) for(auto i=cont.begin();i!=cont.end();i++)
#define ios            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define trace(x)                 cerr << #x << ": " << x << "\n";
#define trace1(x)                cerr << #x << ": " << x << "\n";
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << "\n";
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << "\n";
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << "\n";
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << "\n";
#define ar array
#define endl "\n"
using namespace std;
const int N = 10000001;
int lp[N];
vi prime;
int main(){
    ios;
    rep(i,2,N){
        if(lp[i]==0){
            lp[i]=i;
            prime.pb(i);
        }
        for(ll j=0;j<prime.size() && prime[j]<=lp[i] && i*prime[j]<N;j++){
            lp[i*prime[j]]=prime[j];
        }
    }
    ll n;
    cin>>n;
    ll ans=1;
    rep(i,2,n+1){
        ll y=i;
        ll sol=1;
        while(y!=1){
            ll p=lp[y];
            ll cnt=0;
            while(y%p==0){
                y/=p;
                cnt++;
            }
            // trace(cnt);
            sol*=(cnt+1);
        }
        ans+=(i*sol);
    }
    cout<<ans;
}


Measured memory_bytes: 50608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int MOD= 1e9+7;
int main(){
    long n,k,a=0,b=0;
    cin >> n >> k;
    long c[n];
    rep(i,n) cin >> c[i];
    rep(i,n)rep(j,n){
        if(c[j]<c[i]&&j<i) a++;
        if(c[j]<c[i]&&i<j) b++;
    }
    cout << ((((((k-k%2)/2)*(k-(k-1)%2))%MOD)*a)%MOD+(((((k+1-(k+1)%2)/2)*(k+1-k%2))%MOD)*b)%MOD)%MOD << endl;
}


Measured memory_bytes: 3652
<?php
  fscanf(STDIN, "%s", $s);
$arr = str_split($s);
  if($s=="RRR"){
    echo 3;
  }elseif($s=="SSS"){
    echo 0;    
  }elseif(($arr[0]=="R" && $arr[1]=="R")||($arr[1]=="R" && $arr[2]=="R")){
    echo 2;
  }else{
    echo 1;
  }

?>


Measured memory_bytes: 16168
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <string>
#define _USE_MATH_DEFINES
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define fors(i, a, b) for(int i = a; i < b; i++)
#define fori(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<string, int> > vpsi;
typedef map<string, int> msi;
int main()
{
    ios::sync_with_stdio(false);
    double n;
    cin >> n;
    cout << 2.0 * n * M_PI << endl;
}

Measured memory_bytes: 3820
#include <iostream>
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
vector<PP> v;
int dp[51][11][2],A,B,C,D,a,b,c,d,T[51];
int main(void){
    while(1){
    cin>>A>>B>>C>>D;
    if(A==0)return 0;
    for(int i=0;i<51;i++)for(int j=0;j<11;j++)for(int k=0;k<2;k++)dp[i][j][k]=0;
    for(int i=0;i<51;i++)T[i]=0;
    v={};
    for(int i=0;i<D;i++){
        cin>>a>>b>>c>>d;
        if(d!=0)dp[b][c][0]++;
        else{
            T[b]+=dp[b][c][0]*20;
            dp[b][c][1]=a+1;
        }
    }
    for(int i=1;i<=B;i++){
        int L=0,cnt=0;
        for(int j=1;j<=C;j++){
            if(dp[i][j][1])cnt++;
            L+=dp[i][j][1]-1;
        }
        L+=T[i];
        v.push_back({-cnt,{L,-i}});
    }
    sort(v.begin(),v.end());
    a=v[0].F,b=v[0].S.F,c=v[0].S.S;
    cout<<-c;
    for(int i=1;i<v.size();i++){
        if(a==v[i].F&&b==v[i].S.F)cout<<"=";
        else cout<<",";
        cout<<-v[i].S.S;
        a=v[i].F,b=v[i].S.F,c=v[i].S.S;
    }
    cout<<endl;
    }
}



Measured memory_bytes: 3092
import java.util.Scanner;

public class Main { //クラス名はMain
    public static void main(String[] args) {
        //コード
        Scanner sc = new Scanner(System.in);
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());

        System.out.println(x * y);
        sc.close();
    }
}

Measured memory_bytes: 35612
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	for(int i=0;i<s.size();i++)
		if(s[i]=='C')
			for(int j=i;j<s.size();j++)
			if(s[j]=='F'){cout<<"Yes";return 0;}
	cout<<"No"; 
	return 0; 
} 

Measured memory_bytes: 256
#include<stdio.h>
#define NORMAL 195
#define LEAP 200
int main(void)
{
  int n,m,i,j;/*n:データセットの個数,m:ミレニアム記念日までの日数*/
  scanf("%d",&n);
  int x[n][4];/*0:年,1:月,2:日,3:合計日数*/
  for(i=0;i<n;i++){
    scanf("%d %d %d",&x[i][0],&x[i][1],&x[i][2]);
  }
  m=196470/*=((20*5+19*5)*2+(20*10))*333*/;
  for(i=0;i<n;i++){
    switch((x[i][0]-1)%3){
    case 0 :
      x[i][3]=x[i][2]+(NORMAL*2+LEAP)*((x[i][0]-1)/3);
      x[i][3]=x[i][3]+(x[i][1]-1)/2*39+(x[i][1]-1)%2*20;
      break;
    case 1 :
      x[i][3]=x[i][2]+(NORMAL*2+LEAP)*((x[i][0]-1)/3)+NORMAL;
      x[i][3]=x[i][3]+(x[i][1]-1)/2*39+(x[i][1]-1)%2*20;
      break;
    case 2 :
      x[i][3]=x[i][2]+(NORMAL*2+LEAP)*((x[i][0]-1)/3)+NORMAL*2;
      x[i][3]=x[i][3]+(x[i][1]-1)*20;
      break;
    }
    printf("%d\n", m-x[i][3]+1);
  }
  return 0;
}

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

use proconio::input;
use proconio::marker::{Bytes, Chars, Usize1};
use std::cmp::{Reverse, min, max};
use itertools::Itertools;

fn main() {
    input! {
        a: i64,
        v: i64,
        b: i64,
        w: i64,
        t: i64,
    }

    println!(
        "{}",
        if v > w && (a - b).abs() <= (v - w).abs() * t { "YES" } else { "NO" }
    );
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

vector<vector<int>> all_comb(int n, int k) {
  vector<vector<int>> combs(nCr(n, k), vector<int>(k));
  for(int i=0; i<k; i++) {
    combs[0][i] = i;
    combs[1][i] = i;
  }
  
  for(long i=1; i<nCr(n, k); i++) {
    int p = 1;
    while(combs[i][k - p] == n - p) {
      p++;
      if(p > k) {
        break;
      }
    }
    combs[i][k - p]++;
    int q = combs[i][k - p];
    for(int j=1; j<p; j++) {
      combs[i][k - p + j] = q + j;
    }

    if(i < nCr(n, k) - 1) {
      for(int j=0; j<k; j++) {
        combs[i + 1][j] = combs[i][j];
      }
    }
  }

  return combs;
}

int main() {
  std::cout << std::setprecision(9);
  int x;
  cin >> x;

  if(x >= 30) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>;
using namespace std;
//#define LOCAL
typedef long long ll;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)

int main(){
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
     //freopen("out.txt", "w", stdout);
#else
 fastIO;
#endif
//***************************//**************************//******************************
char p;
cin>>p;
if(p>='A' && p<='Z'){
    cout<<"A"<<endl;
}else{
cout<<'a'<<endl;
}
}



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

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(auto i = 0; i < n; ++i){
		int l, r;
		cin >> l >> r;
		ans += (r - l + 1);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto &a : A) cin >> a;
  reverse(A.begin(), A.end());
  const int inf = 1e9 + 5;
  vector<int> lis(N, inf);
  for (int i = 0; i < N; i++) {
    *upper_bound(lis.begin(), lis.end(), A[i]) = A[i];
  }
  int ans = lower_bound(lis.begin(), lis.end(), inf) - lis.begin();
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<string>s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    map<string, int> m;
    for(int i = 0; i < n; i++){
        m[s[i]]++;
    }
    int maxnum = -1;
    for(int i = 0; i < n; i++){
        maxnum = max(maxnum, m[s[i]]);
    }
    vector<string> t;
    for(int i = 0; i < n; i++){
        if(m[s[i]] == maxnum) t.push_back(s[i]);
    }
    std::sort(t.begin(), t.end());
    t.erase(std::unique(t.begin(), t.end()), t.end());
    for(int i = 0; i < t.size(); i++) cout << t[i] << endl;
    
}


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

using namespace std;

int n;
string s;
int a[2001], cnt[2001];
int low[2001], high[2001];
vector<int> AdjList[2001];

int res = 1e9;

int dfs(int u,int p)
{
	cnt[u] = a[u];
	low[u] = high[u] = 0;
	int mx_l = -1e9;
	for (int i=0;i<AdjList[u].size();i++)
	{
		int v = AdjList[u][i];
		if (v != p)
		{
			dfs(v,u);
			cnt[u] += cnt[v];
			high[u] += (high[v] + cnt[v]);
			low[v] += cnt[v];
			high[v] += cnt[v];
			mx_l = max(mx_l,low[v]);
		}      
	}
	low[u] = high[u]%2;
	if (mx_l != -1e9)
	{
		int sum = 0;
		for (int i=0;i<AdjList[u].size();i++)
		{
			int v = AdjList[u][i];
			if (v != p)
			{
				if (high[v] < mx_l) sum += high[v];
				else if ((low[v] % 2) != (mx_l % 2)) sum += (mx_l-1);
				else sum += mx_l;
			}
		}
		low[u] = max(low[u],mx_l*2 - sum); 
	}
	//cerr << u << ' ' << mx_l << ' ' << high[u] << ' ' << low[u] << '\n';
	if ((low[u] == 0) && (high[u] % 2 == 0)) return high[u] / 2;
	return 1e9;
}

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

	cin >> n >> s;
	for (int i=0;i<s.size();i++)
		a[i+1] = (s[i] - '0');
	for (int i=1;i<=n-1;i++)
	{
		int u,v;
		cin >> u >> v;
		AdjList[u].push_back(v);
		AdjList[v].push_back(u);
	}
	//dfs(2,-1);
	for (int i=1;i<=n;i++)
		res = min(res,dfs(i,-1));
	if (res == 1e9) cout << -1;
	else cout << res;
}

Measured memory_bytes: 640
A=sorted(list(map(int,input().split())))
n=0
while A[1]!=A[2]:
  A[0]+=1
  A[1]+=1
  n+=1
a=A[2]-A[0]
if a%2==0:
  n+=a//2
else:
  n+=1
  n+=(a+1)//2
print(n)

Measured memory_bytes: 3060
S=input()
# S="".join(["?" for _ in range(10**5)])
# S = "??2??5"
# S= "?44"

MOD = 10**9+7
dp = [[0 for i in range(13)] for j in range(len(S)+1)]
dp[0][0] = 1
for t,ss in enumerate(S[::-1]):
    if t==0:
        tt = 1
    else:
        tt = (10*tt)%13
    if ss=="?":
        for i in range(13):
            for j in range(10):
                k = (j*tt+i)%13
                dp[t+1][k] += dp[t][i]%MOD
    else:
        s = int(ss)
        for i in range(13):
            k = (s*tt+i)%13
            dp[t+1][k] += dp[t][i]%MOD

print(dp[t+1][5]%MOD)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long  ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    ll k; cin >> k;
    ll n = s.size();
    ll res = 0;
    rep(i,n){
        if(s[i] != 'a'){
            ll sum = 'z' - s[i] + 1; //どのくらいで変えられるか
            if(res + sum <= k)s[i] = 'a',res+=sum;
        }
    }
    ll ans = k - res;
    s[n-1] = s[n-1] + (ans%26);
    out(s);
}


Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
#define max1 100001

long long int mod=1e9 +7 ;


int main(){	
	int h,w;
	cin>>h>>w;
	vector<string> a(h);
	for (int i = 0; i < h; ++i)
	{
		cin>>a[i];
	}
	long long int dp[h][w];
	for(int i=0;i<h;i++){
		for (int j = 0; j <w; ++j)
		{
			if(i==0&&j==0){
				dp[i][j]=1;
				continue;
			}
			dp[i][j]=0;
			if(a[i][j]=='#')
				continue;
			if(i>0){
				if(a[i-1][j]=='.')
					dp[i][j]+=dp[i-1][j];
			}
			if(j>0){
				if(a[i][j-1]=='.'){
					dp[i][j]+=dp[i][j-1];
				}
			}
			dp[i][j]=dp[i][j]%mod;
		}
	}
	cout<<dp[h-1][w-1]<<endl;




		
}
	
	
	
	





Measured memory_bytes: 9216
#include <stdio.h>
#include <string.h>

int main() {
	long long int a;
	
	char ans[255] = {};
		
	scanf("%lld", &a);

	int i = 0;

		while(a > 0) {
			a--;
			ans[i] = 'a' + (a % 26);
			a /= 26;
			i++;
		}
	
	ans[i] = '\0';
	int len = strlen(ans);
	for(len--; len >= 0; len--) {
	
	printf("%c", ans[len]);
	
	}
	
	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef pair<int, int> pr;
typedef vector<vector<pr>> vv;
typedef long long ll;

int main()
{
    int n, m;
    cin >> n >> m;

    vv city(n + 1);
    for (int i = 0; i < m; i++)
    {
        int p, y;
        scanf("%d %d", &p, &y);
        city[p].push_back(pr(y, i));
    }

    vector<ll> ans(m);
    for (int i = 0; i < n + 1; i++)
    {
        auto c = city[i];
        sort(c.begin(), c.end());
        for (int j = 0; j < c.size(); j++)
        {
            ans[c[j].second] = i * 1000000LL + j + 1;
        }
    }

    for (auto no : ans)
    {
        printf("%012lld\n", no);
    }

    return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
 
using namespace std;
int a[205][205];
 
int main() {
	memset(a, 0, sizeof(a));
	int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    int x = 1, y = 1;
    for(int i = 1; i <= k; i ++) {
    	int cnt = 0;
        scanf("%d", &cnt);
        while(cnt --) {
			a[x][y] = i;
			if(y == m && (x & 1)) y = m, x ++;
			else if(y == 1 && !(x % 2)) y = 1, x ++;
			else if(x & 1) y ++;
			else y --;
        }
    }
    for(int i = 1; i <= n; i ++)
   		for(int j = 1; j <= m; j ++)
        printf("%d%c", a[i][j], j == m ? '\n' : ' ');
    return 0;
}

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

using namespace std;

#define endl '\n'

#define pb push_back
#define f first
#define s second
#define BUFF ios::sync_with_stdio(false);

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

mt19937 rng((int) chrono::steady_clock::now().time_since_epoch().count());

const int MAX = (int)1e5+10;

ll dp[MAX][3];
ll a[MAX][3];

int main(){

    BUFF;

	int n; cin >> n;

	for( int i=0; i<n; i++ ){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}

	memset(dp, 0, sizeof(dp));

	for( int i=n-1; i>=0; i-- ){
		for( int j=0; j<3; j++ ){
			dp[i][j] = a[i][j] + max(dp[i+1][(j+1)%3], dp[i+1][(j+2)%3]);
		}
	}

	ll resp=0;
	
	for( int i=0; i<3; i++ ){
		resp = max(resp, dp[0][i]);
	}

	cout << resp << endl;
	
	

    return 0;
}


Measured memory_bytes: 4992
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) (a*a)
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int a[100000];

int main() {
	int n, l;
	scanf("%d%d", &n, &l);
	REP(i, n)scanf("%d", a + i);
	int target = -1;
	REP(i, n - 1)if (a[i] + a[i + 1] >= l)target = i;
	if (target == -1) {
		cout << "Impossible" << endl;
		return 0;
	}
	cout << "Possible" << endl;
	REP(i, target)printf("%d\n", i + 1);
	for (int i = n - 2; i >= target; i--)printf("%d\n", i + 1);
	return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )
#define repd(i,a) for( int i = (a); i >= 0; --i )
#define repi(i,a,b) for( int i = (a); i != (b); ++i )

typedef unsigned long long ull;

const ull units[4] = { 20, 18, 20, 20 }, cycle = 13*20*20*20*18;

bool isLeap( ull y )
{
	return ( y % 4 == 0 && y % 100 ) || y % 400 == 0;
}

ull dayOfMonth( ull y, ull m )
{
	switch( m )
	{
		case 2:
			if( isLeap( y ) )
				return 29;
			else
				return 28;
		case 4:
		case 6:
		case 9:
		case 11:
			return 30;
		default:
			return 31;
	}
}

ull GetDays(ull y, ull m, ull d)
{
	// 1・2月 → 前年の13・14月
	if (m <= 2)
	{
		--y;
		m += 12;
	}
	ull dy = 365 * (y - 1); // 経過年数×365日
	ull c = y / 100;
	ull dl = (y >> 2) - c + (c >> 2); // うるう年分
	ull dm = (m * 979 - 1033) >> 5; // 1月1日から m 月1日までの日数
	return dy + dl + dm + d - 1;
}

int main()
{
	std::string s;
	while( std::cin >> s, s != "#" )
	{
		ull now = GetDays( 2012, 12, 21 );

		// y.m.d
		if( std::count( s.begin(), s.end(), '.' ) == 2 )
		{
			ull y, m, d;
			rep( i, s.size() )
				if( s[i] == '.' )
					s[i] = ' ';

			std::istringstream iss(s);
			iss >> y >> m >> d;

			ull nxt = GetDays( y, m, d );
			nxt -= now;
			nxt %= cycle;

			std::vector<ull> v;
			rep( i, 4 )
			{
				v.push_back( nxt % units[i] );
				nxt /= units[i];
			}
			v.push_back( nxt );
			repd( i, 4 )
				printf( "%llu%c", v[i], ".\n"[!i] );
		}
		// b.ka.t.w.ki
		else
		{
			ull a[5];
			rep( i, s.size() )
				if( s[i] == '.' )
					s[i] = ' ';

			std::istringstream iss(s);
			rep( i, 5 )
				iss >> a[i];
			
			ull days = 0;
			repd( i, 5 )
			{
				days += a[4-i];
				if( i )
					days *= units[i-1];
			}
			ull y = 2012, m = 12, d = 21;
			while( true )
			{
				ull lim = dayOfMonth( y, m )-d+1;
				if( days < lim )
				{
					d += days;
					break;
				}
				days -= lim;
				d = 1;
				++m;
				if( m > 12 )
					m = 1, ++y;
			}

			printf( "%llu.%llu.%llu\n", y, m, d );
		}
	}

	return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;

int main() {
	int n, m;
	cin >> n >> m;

	int k[50], a[50][50];
	rep(i, n){
		cin >> k[i];
		rep(j, k[i]){
			cin >> a[i][j];
		}
	}

	int sum;
	int ans = 0;
	int num = 1;
	rep(y, m){
		sum = 0;
		rep(i, n){
			rep(j, k[i]){
				if(a[i][j] == num){
					sum++;
				}
			}
		}
		if(sum == n){
			ans++;
		}
		num++;
	}


	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

ll gcd(ll a, ll b) {
  if (a == 0 || b == 0) return a + b;
  if (b > a) return gcd(b, a);
  return gcd(b, a % b);
}

int main(void) {

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

  int k = 1, l = m + 2;

  while (true) {
    cout << k << " " << k + m << endl;
    k++; m--;
    if (m <= 0) return 0;
    cout << l << " " << l + m << endl;
    l++; m--;
    if (m <= 0) return 0;
  }
  return 0;
}
    


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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> tonari(n);//隣接する部屋たち
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;//
    tonari.at(a).push_back(b);
    tonari.at(b).push_back(a);
  }
  
  
  //bfs
  queue<int> q;
  vector<int> dist(n, 1000000);//部屋1からの距離
  vector<int> mae(n, -1);//直前の頂点
  q.push(0);
  dist.at(0) = 0;
  
  while(!q.empty()){
    int u = q.front();
    q.pop();
    for(int v: tonari.at(u)){
      if(dist.at(v) == 1000000){
        dist.at(v) = dist.at(u) + 1;
        mae.at(v) = u;
        q.push(v);
      }
    }
  }
  
  
  cout << "Yes" << endl;
  for(int i = 1; i < n; i++){
    int ans = mae.at(i);
    ans++;//
    cout << ans << endl;
  }
}

Measured memory_bytes: 10736
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
ans = 0
for i in range(N):
  eat = A[i]
  if i != 0:
    rireki = A[i-1]
  ans += B[eat-1]
  if i != 0 and rireki == eat-1:
    ans += C[rireki-1]
    
print(ans)
    
    

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

using namespace std;

const double EPS = 1e-7;
const int N = 4e5+5, M = 1e5+5, OO = 0x3f3f3f3f;
typedef long long ll;

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


int n,x,A[200000];
int main(){
    cin>>n;
    int mx1=0,mx2=0;
    for(int i=0; i<n; i++){
       cin>>x;
       A[i]=x;
       if(x>mx1)mx1=x;
       else{
        if(x>mx2)mx2=x;
       }
    }
    for(int i=0; i<n; i++){
        if(A[i]!=mx1)cout<<mx1<<endl;
        else cout<<mx2<<endl;
    }
}



Measured memory_bytes: 2432
#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 x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a)>abs(x-b)) cout << 'B' << endl;
    else cout << 'A' << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>
#include <utility>

using namespace std;

int main()
{
	unsigned long long int n,sum = 0;
	cin >> n;

	for (int i = 1; i <= n; i++)
	{
		if (i % 3 != 0 && i % 5 != 0)
			sum += i;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)
#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)
#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl


int main(){
    int n;
    cin>>n;
    n--;
    string bef,now;
    cin>>bef;
    set<string> a;
    a.insert(bef);
    bool flag=true;
    REP(i,n){
        cin>>now;
        cerr<<bef[sz(bef)-1]<<endl;
        if(bef[sz(bef)-1]!=now[0]||
            a.count(now)!=0){
                flag=false;
                break;
        }
        a.insert(now);
        bef=now;
    }
    Yes(flag);
    return 0;
}

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

sum_A = 0
sum_A_even = 0
for n in range(N):
    sum_A += A[n]
    if (n+1) % 2 == 0:
        sum_A_even += A[n]

x1 = sum_A - 2*sum_A_even
ans=[x1]

for n in range(N-1):
#     print(n,ans)
    x_ = ans[n]
    x = 2*A[n] - x_
    ans.append(x)
    
print(' '.join(map(str,ans)))

Measured memory_bytes: 101472
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
const int N = 13;
int a[N][N];
int c[N];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n , m, x;
	cin >> n >> m >> x;
	for (int i = 0; i < n; ++i) {
		cin >> c[i];
		for (int j = 0; j < m; ++j) {
			cin >> a[i][j];
		}
	}
	ll ans = 1e10;
	for (int bit = 0; bit < (1 << n); ++bit ) {
		ll cost = 0;
		vector<int> temp(n, 0);
		for (int i = 0; i < n; ++i) {
			if (bit & (1 << i)) {
				cost += c[i];
				for (int j = 0; j < m; ++j) {
					temp[j] += a[i][j];
				}
			}
		}
		bool flag = true;
		for (int i = 0; i < m; ++i) {
			if (temp[i] < x) {
				flag = false;
				break;
			}
		}
		if (flag) {
			ans = min(ans, cost);
		}
	}
	if (ans == 1e10)
		cout << "-1";
	else
		cout << ans << "\n";
}


Measured memory_bytes: 3644