akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n, m, s, t;
  scanf("%lld %lld %lld %lld", &n, &m, &s, &t);
  map<long long, vector<long long>> D;
  map<long long, long long> DM;
  map<long long, long long> DS;
  long long u, v, a, b;
  long long tmpl, tmpr;
  for (int i=0;i<m;i++){
    scanf("%lld %lld %lld %lld", &u, &v, &a, &b);
    if (D.count(u-1)){
      D[u-1].push_back(v-1);
    }
    else{
      D[u-1] = {v-1};
    }
    if (D.count(v-1)){
      D[v-1].push_back(u-1);
    }
    else{
      D[v-1] = {u-1};
    }
    tmpl = (u-1) * n + (v-1);
    tmpr = (v-1) * n + (u-1);
    DM[tmpl] = a, DM[tmpr] = a;
    DS[tmpl] = b, DS[tmpr] = b;
  }
  vector<long long> dm(n, 1e18);
  vector<long long> ds(n, 1e18);
  dm[s-1] = 0, ds[t-1] = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> pqm;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> pqs;
  for (int i=0;i<n;i++){
    pqm.push(make_pair(dm[i], i));
    pqs.push(make_pair(ds[i], i));
  }
  pair<long long, long long> M;
  pair<long long, long long> S;
  long long r;
  while (!pqm.empty()){
    M = pqm.top();
    pqm.pop();
    r = M.second;
    for (long long i : D[r]){
      if (dm[i] > dm[r] + DM[r*n+i]){
        dm[i] = dm[r] + DM[r*n+i];
        pqm.push(make_pair(dm[i], i));
      }
    }
  }
  while (!pqs.empty()){
    S = pqs.top();
    pqs.pop();
    r = S.second;
    for (long long i : D[r]){
      if (ds[i] > ds[r] + DS[r*n+i]){
        ds[i] = ds[r] + DS[r*n+i];
        pqs.push(make_pair(ds[i], i));
      }
    }
  }
  vector<long long> X(n);
  for (int i=0;i<n;i++){
    X[i] = dm[i] + ds[i];
  }
  vector<long long> Y(n, 1e17);
  long long mm = 1e17;
  for (int i=n;i>0;i--){
    if (mm > X[i-1]){
      mm = X[i-1];
    }
    Y[i-1] = mm;
  }
  long long Max = 1e15;
  for (int i=0;i<n;i++){
    printf("%lld\n", Max - Y[i]);
  }
  return 0;
}

Measured memory_bytes: 46348
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include<list>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N;
    cin>>N;
    vector<int>v;
    vector<int>w;
    for(int i=0;i<N;i++){
        int x;
        cin>>x;
        v.push_back(x);
        w.push_back(x);
    }
    sort(v.begin(),v.end());
    for(int i=0;i<N;i++){
        if(w[i]<v[N/2])cout<<v[N/2]<<endl;
        else cout<<v[N/2-1]<<endl;

    
    }




    return 0;
}

Measured memory_bytes: 3948
program abc160d
      implicit none
      integer::i,j,k
      integer::n,x,y,d1,d2,low
      integer,allocatable,dimension(:)::d

!refered to "w49b"

      read *,n,x,y
      allocate(d(n-1))
      d=0

      do i=1,n-1
         do j=i+1,n
            d1=j-i      ! not use X-Y edge
            d2=abs(x-i)+abs(y-j)+1  !use X-Y edge
            if (d1<d2) then
               low=d1
            else
               low=d2
            end if
            d(low)=d(low)+1
         end do
      end do

      do k=1,n-1
         print *,d(k)
      end do
      stop

   end program abc160d

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int v,i,n,j,A[100];
int count = 0;
scanf("%d",&n);
for(i = 0;i < n;i++){
scanf("%d",&A[i]);}

for(j = 0;j < n;j++){
 for(i = n-1;i > j; i--){
  if(A[i]<A[i-1]){
  v = A[i];
  A[i] = A[i - 1];
  A[i - 1] = v;
  count++;
  }
 }
}
  for(i = 0;i < n;i++){
  if(i == n-1){
  printf("%d\n",A[i]);
}
  else {
  printf("%d ",A[i]);
}
}
  printf("%d\n",count);

 return 0;
}

Measured memory_bytes: 1812
#include<stdio.h>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))

bool binarySearch(int key,int S[], int n) {
    int left = 0;
    int right = n;

    while(left < right) {
        int mid = (left + right) / 2;
        if(S[mid] == key) {
            return true;
        }
        if(S[mid] < key) {
            left = mid + 1;
        }
        else{
            right = mid;
        }
    }
    return false;

}

int main() {
    int n,q;
    int S[100005];
    int count = 0;
    // 入力
    scanf("%d",&n);
    rep(i,n) {
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    
    // テスト
    rep(i,q) {
        int key;
        scanf("%d",&key);
        if(binarySearch(key,S,n)) {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


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

using namespace std;

typedef long long ll;

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

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

	n %= 500;
	if(n <= a){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}


Measured memory_bytes: 256
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

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

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//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 EACH(i, c) for (auto 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, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const long long INFL = __LONG_LONG_MAX__ / 10;
const int INFI = __INT_MAX__ / 10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
//                       << " " << __FILE__ << endl;

const int LimitN=400;
LL A[LimitN];
LL sums[LimitN+1];
LL dp[LimitN][LimitN];


int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;
    sums[0] = 0;
    REP(i, N){
        LL a;
        cin >> a;
        A[i] = a;
        sums[i+1] = sums[i] + a; 
        dp[i][i] = 0;
    }


    for(int len=1; len <= N ; len++){
        for(int left=0; left+len < N; left++){
            int right = left+len;
            LL ans = __LONG_LONG_MAX__ / 10;
            for(int sep = left+1; sep <= right; sep++){
                LL mid = (sums[sep] - sums[left]) + (sums[right+1] - sums[sep]) +dp[left][sep-1] + dp[sep][right];
                ans = min(
                    mid
                    , ans
                );
                // cout << left << ", " << sep << ", " << right << ", " << mid << endl;
            }
            dp[left][right] = ans;
            // cout<< left << ", " << right << ", " << dp[left][right] <<endl;
        }
    }
    
    cout << dp[0][N-1] << endl;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n], b[n], c[n-1];
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i]--;
  }
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n-1; i++){
    cin >> c[i];
  }
  int sum =0;
  int pre = -1;
  for(int i = 0; i < n; i++){
    sum += b[a[i]];
    if(pre == a[i]-1){
      sum += c[a[i]-1];
    }
    pre = a[i];
  }
  cout << sum;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		
		List<long> L = new List<long>();
		if(N == S){
			L.Add(N+1);
		}
		
		for(long b=2;b*b<=N;b++){
			if(digSum(N,b) == S) {
				L.Add(b);
			}
		}
		
		
		
		for(long x=1;x*x<=N;x++){
			// N = xb + y;
			// S = x + y
			long y = S - x;
			if( (N - y)%x == 0){
				long b = (N-y)/x;
				if(b*x + y == N && x<b && y<b && x>=0 && y>= 0)L.Add(b);
			}
		}
		if(L.Count == 0){
			Console.WriteLine(-1);
			return;
		}
		Console.WriteLine(L.Min());
		
		
	}
	
	static long digSum(long n,long b){
		long ret = 0;
		while(n>0){
			ret += n%b;
			n /= b;
		}
		return ret;
	}
	
	long N,S;
	public Sol(){
		N = rl();
		S = rl();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2776
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long maxi = 0,ans = 0;
  vector<long long> a(n);

  for(int i = 0;i < n;i++){
    cin >> a[i];
    if(maxi<= a[i])maxi = a[i];
    else ans += maxi - a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4840
n, m = map(int, input().split())
d = []
for i in range(m):#h:高さ
    d.append([int(m) for m in input().split()])
e = []
for i in range(m):
    e.append([])
for i in range(m):
    e[i].append(d[i][0] - 1)
    e[i].append(d[i][1] - 1)
    e[i].append(-d[i][2])
#edges = d
#num_v = n
#source = m


#ベルマンフォード
#高々|V|-1回で最安定経路にたどり着くっていうのがなかなか理解できなくて、紙に書きながら理解した。

"""edge = [[0,1,2],[0,2,5],[1,2,4],[1,3,6],[1,4,10],[2,3,2],[3,5,1],[4,5,3],[4,6,5],[5,6,9],
       [1,0,2],[2,0,5],[2,1,4],[3,1,6],[4,1,10],[3,2,2],[5,3,1],[5,4,3],[6,4,5],[6,5,9]]"""
edge = e

def shortest_path(edge,num_v,start):
    inf = float("inf")
    d = [inf for f in range(num_v)]
    d[start] = 0;
    for i in range(num_v):
        update = False
        for e in edge:
            if d[e[0]] != inf and d[e[1]] > d[e[0]] + e[2]:
                d[e[1]] = d[e[0]] + e[2]
                update = True
        if not update:
            break
        if i == num_v - 2:
            k = d[-1]
        if i == num_v - 1 and k != d[-1]:
            d[n - 1] = -inf
            break
    return d

print(-shortest_path(edge,n,0)[n - 1])
#print("inf")
#print(BellmanFord(e, n, m))
"""5 5
1 2 2
2 5 4
4 3 1
3 4 2
2 4 1"""

Measured memory_bytes: 3828
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 1;
    for (int i=1; i * i <= n; ++i){
        ans = i * i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String P = scanner.next().toLowerCase();
		char p[] = P.toCharArray();

		String tmp;
		int ans = 0;
		boolean FLG;

		while(!(tmp = scanner.next()).equals("END_OF_TEXT")){

			char line[] = tmp.toLowerCase().toCharArray();

			if(line.length != p.length)continue;

			FLG = true;
			for(int i = 0; i < P.length(); i++){
				if(p[i] != line[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)ans++;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 25960
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "Yes"
#define NO  "No"

using namespace std;

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

  int num;
  int tmp;

  int n; cin >> n;
  string s; cin >> s;

  // map<int, int> mem; // iまでの#ではない数.
  vector<int> mem(n);
  
  tmp = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] != '#') tmp++;
    mem[i] = tmp;
    // mem.insert(make_pair(i + 1, tmp));
  }

  num = n;

  for (int i = 0; i <= n; ++i) {
    int tmp;

    if (i == 0) { // bbbbbb
      // tmp = mem.at(n);
      tmp = mem[n - 1];
    } else if (i == n) { // wwwwww
      // tmp = n - mem.at(n);
      tmp = n - mem[n - 1];
    } else { // wwwbbb
      // tmp = i + mem.at(n) - 2 * mem.at(i);
      tmp = i + mem[n - 1] - 2 * mem[i - 1];
    }
    num = min(num, tmp);
  }
  
  cout << num << endl;
  
  return 0;
}


Measured memory_bytes: 2196
#[allow(dead_code)]
fn scan<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn scan_split<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_split_with<T: std::str::FromStr>(ch: char) -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split(ch)
        .map(|t| t.parse().ok().unwrap()).collect()
}

#[allow(dead_code)]
fn scan_lines<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| scan::<T>()).collect()
}

#[allow(unused_macros)]
macro_rules! scan_as_tuple {
    ( $t:ty ) => {
        (scan::<$t>(),)
    };
    ( $( $t:ty ),* ) => {
        {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).ok();
            let v = s.trim().split_whitespace();
            let mut it = v;
            let ret = ( $(it.next().unwrap().parse::<$t>().ok().unwrap()),* );
            assert!(it.next() == None, "not all tokens consumed");
            ret
        }
    };
}

fn main() {
    let c = scan::<String>();
    println!("{}", match c.chars().nth(0).unwrap() {
        'a' | 'i' | 'u' | 'e' | 'o' => "vowel",
        _ => "consonant",
    });
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define str string
#define all(x) (x).begin(),(x).end()
#define rep(x,b,c) for(int x=b;x<c;x++)
#define  pb(x) push_back(x)
#define long(x) x.size()
int main(){
    int num[40]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<num[k-1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

int main() {

    bool used[10];
    REP(i,10) used[i] = false;

    int N; cin >> N;
    int cnt = 0;
    REP(i,N) {
        int a; cin >> a;
        if(a >= 1 && a <= 399) used[0] = true;
        if(a >= 400 && a <= 799) used[1] = true;
        if(a >= 800 && a <= 1199) used[2] = true;
        if(a >= 1200 && a <= 1599) used[3] = true;
        if(a >= 1600 && a <= 1999) used[4] = true;
        if(a >= 2000 && a <= 2399) used[5] = true;
        if(a >= 2400 && a <= 2799) used[6] = true;
        if(a >= 2800 && a <= 3199) used[7] = true;
        if(a >= 3200) cnt++;
    }

    int ans = 0;
    REP(i,10) if(used[i]) ans++;

    if(ans == 0 && cnt >0) {
        cout << 1 << " " << cnt << endl;
        return 0;
    }

    cout << ans << " " << ans + cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	int x,a,b;
	cin >> x >> a >> b;
	x -= a;
	x = x %b;
	cout << x << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())

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)

times = 10**12

for j in range(len(divisors)):
    x = divisors[j]
    y = n // x
    time = (x -1) + (y - 1)
    if time < times:
      times = time
print(times)


Measured memory_bytes: 3268
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	inputs := scanIntNums()
	N := inputs[0]

	inputs = scanIntNums()
	var sum int
	for _, input := range inputs {
		sum += input
	}
	if N-sum < 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(N - sum)
	}
}

func scanIntNums() (nums []int) {
	sc.Scan()
	numString := strings.Split(sc.Text(), " ")

	nums = make([]int, len(numString))
	var err error

	for i := 0; i < len(nums); i++ {
		nums[i], err = strconv.Atoi(numString[i])
		if err != nil {
			panic(err)
		}
	}
	return nums
}


Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

// utility comparator function to pass to the sort() module
// 降順 5,4,3,2,...
bool sortByVal(const pair<string, int> &a, 
               const pair<string, int> &b) 
{ 
    return (a.second > b.second); 
}

int main(){
  
  ll n;
  cin >> n;

  map<string, int>papers;
  rep(i, n){
    string input;
    cin >> input;
    
    if (papers.find(input)==papers.end()){
      papers[input] = 1;
    }else{
      papers[input] = papers[input] + 1;
    }
  }

  // // debug
  // for (auto it=papers.begin(); it!=papers.end(); it++){
  //   cout << "[" << it->first << "] : " << it->second << endl;
  // }

  vector<pair<string, int>> vec;
  // copy key-value pairs from the map to the vector
  map<string, int> :: iterator it;
  for (it=papers.begin(); it!=papers.end(); ++it){
    vec.push_back(make_pair(it->first, it->second));
  }

  // cout << "BEFORE SORTED" << endl;
  // for (int i = 0; i < vec.size(); i++)
	// {
	// 	cout << vec[i].first << ": " << vec[i].second << endl;
	// }

  sort(vec.begin(), vec.end(), sortByVal);

  // cout << "AFTER SORTED" << endl;
	// for (int i = 0; i < vec.size(); i++)
	// {
	// 	cout << vec[i].first << ": " << vec[i].second << endl;
	// }

  // answer
  int max_v = vec[0].second;
  vector<string> ans(vec.size());
  int j=0;
  rep(i, vec.size()){
      if (vec[i].second == max_v){
        ans[j] = vec[i].first;
        j++;
        // cout << vec[i].first << endl;
      }
  }

  sort(ans.begin(), ans.end());

  rep(i, ans.size())
    cout << ans[i] << endl; 

  return 0;
}

Measured memory_bytes: 30576
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(input())

pos = (0, 0)
pre = 1
nxt = 0
while True:
    x, y = pos
    if x<w-1 and a[y][x+1]=='#':
        nxt += 1
        pos = (x+1, y)
    if y<h-1 and a[y+1][x]=='#':
        nxt += 1
        pos = (x, y+1)
    if x>0 and a[y][x-1]=='#':
        pre += 1
    if y>0 and a[y-1][x]=='#':
        pre += 1
    if pos==(w-1, h-1) and nxt==0 and pre==1:
        print('Possible')
        break
    if nxt!=1 or pre!=1:
        print('Impossible')
        break
    pre = 0
    nxt = 0

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

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REP2(i, a) REP3(i, 0, a)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += (s))
#define REPR(...) GET_MACRO(__VA_ARGS__, REPR4, REPR3, REPR2)(__VA_ARGS__)
#define REPR2(i, a) REPR3(i, 0, a)
#define REPR3(i, a, b) REPR4(i, a, b, 1)
#define REPR4(i, a, b, s) for (int i = (b)-1; i >= (int)(a); i -= (s))
#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) (std::cerr << #x << ':' << ' ' << x << '\n')
#define TMPL_T template <typename T>
#define TMPL_TU template <typename T, typename U>
#define mut auto
#define let const auto

using Int = long long;
// clang-format off
namespace extio {
std::string delimiter=" ",pdelimiter=" ";
std::string bracket_b="",bracket_e="";
void chdelim(const std::string&s){delimiter=s;}
void chpdelim(const std::string&s){pdelimiter=s;}
void chbracket(const std::string&b,const std::string&e){bracket_b=b,bracket_e=e;}
TMPL_T  void pcont(std::ostream&os,const T&x){int c=0;for(const auto&a:x){if(c++)os<<delimiter;os<<a;}}
TMPL_TU void ppair(std::ostream&os,const std::pair<T,U>&p){os<<bracket_b<<p.first<<pdelimiter<<p.second<<bracket_e;}
}
namespace std {
TMPL_T ostream& operator<<(ostream&os,const vector<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const set<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const multiset<T>&x){extio::pcont(os,x);return os;}
TMPL_T ostream& operator<<(ostream&os,const deque<T>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const map<T,U>&x){extio::pcont(os,x);return os;}
TMPL_TU ostream& operator<<(ostream&os,const pair<T,U>&x){extio::ppair(os,x);return os;}
}
TMPL_TU inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
TMPL_TU inline bool chmin(T&x,U a){return a<x&&(x=a,1);}

inline int in(){int x;std::cin>>x;return x;}

struct Initializer_ {
  Initializer_(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(0);
    std::cout << std::setprecision(10);
    std::cerr << std::setprecision(10);
  }
} precalc;
// clang-format on
// }}}

using namespace std;

signed main() {
  int a, b;
  while (cin >> a >> b) {
    cout << to_string(a + b).size() << endl;
  }
  return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){
  ll n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> mp;
  ll a, b, c;
  for(ll i = 0; i < n; i++){
    cin>>a;
     mp.push_back(make_pair(a,1));
  }
  for(ll i = 0; i < m; i++){
    cin >> b >> c;
    bool find = false;
    mp.push_back(make_pair(c,b));
  }

  sort(mp.begin(), mp.end());
  reverse(mp.begin(), mp.end());

  ll ans = 0;
  ll tmp = n;
  for(int i = 0; i < n; i++){
    int m = min(mp[i].second, tmp);
    //mp[i].second -= m;
    tmp -= m;
    ans += m*mp[i].first;

    if(tmp == 0){
      break;
    }
  }
  cout << ans << endl;
  return 0;
} 


Measured memory_bytes: 6256
N, K = map(int, input().split())
lopFlg = True
ansLst = 0
ans = 0
for i in range(1, N + 1):
    tmp = i * 2
    cnt = 1
    while True:
        if i >= K:
            ans += 1
            break
        if K > tmp:
            tmp = tmp * 2
            cnt += 1
        else:
            ans += float(1 / (2 ** cnt))
            break

ans = 1 / N * ans
print(ans)


Measured memory_bytes: 3060
// Create your own template by modifying this file!
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

#define endl ("\n")
#define pi (3.141592653589)
#define mod 1000000007
#define int long long
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;

int32_t main() 
{
	int t;
	cin >> t;
	if (t==0) cout << 1 << endl;
    else cout << 0;
}




Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main() {

    int w, h, n;
    cin >> w >> h >> n;
    int x1 = 0, x2 = 0, y1 = 0, y2 = 0;

    for(int i = 0; i < n; ++i){
        int x, y, a;
        cin >> x >> y >> a;
        if(a == 1){
            if(x1 < x)x1 = x;
        }else if(a == 2){
            if(x2 < w-x)x2 = w-x;
        }else if(a == 3){
            if(y1 < y)y1 = y;
        }else if(a == 4){
            if(y2 < h-y)y2 = h -y;
        }
        }

    if((w-x1-x2) > 0 && (h-y1-y2)>0)cout << (w-x1-x2)*(h-y1-y2) << endl;
    else cout << 0 << endl;

}

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

#define MAX 100

int min(int,int);

int main(){
  int m[MAX + 1][MAX + 1];
  int p[MAX + 1];
  int n;
  int i,j,k,l;
  
  scanf("%d",&n);

  for (i = 1;i <= n;i++){
    scanf("%d %d",&p[i - 1],&p[i]);
  }

  for (i = 1;i <= n;i++)
    m[i][i] = 0;
  
   for (l = 2;l <= n;l++){
    for (i = 1;i <= n - l + 1;i++){
      j = i + l - 1;
      m[i][j] = INT_MAX;

      for (k = i;k <= j - 1;k++){
	m[i][j] = min(m[i][j],m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
      }
      
    }
    
  }

  printf("%d\n",m[1][n]);

  return 0;
}

int min(int x,int y){
  if (x < y)
    return x;

  return y;
}




Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iterator>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define SI size()
#define VE vector<int>
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define LL long long
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int N;
int A[200000];
int L[200000];
int R[200000];
int S=0;
int main(){
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  VE V;
  FOR(i,0,N){
    while(!V.empty()&&A[V.back()]>A[i]){
      V.pop_back();
    }
    if(V.empty()){
      L[i]=0;
    }else{
      L[i]=V.back()+1;
    }
    V.PB(i);
  }
  V.clear();
  ROF(i,0,N){
    while(!V.empty()&&A[V.back()]>A[i]){
      V.pop_back();
    }
    if(V.empty()){
      R[i]=N-1;
    }else{
      R[i]=V.back()-1;
    }
    V.PB(i);
  }
  LL ans=0;
  FOR(i,0,N){
    ans+=(LL)A[i]*(R[i]-i+1)*(i-L[i]+1);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3448
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll n;
  cin >> n;
  map<ll,ll> mp;
  REP(i,n){
    ll a;
    cin >> a;
    mp[a-1]++;
    mp[a]++;
    mp[a+1]++;
  }
  ll max = 0;
  for(auto m:mp){
    if(m.second>max) max = m.second;
  }
  cout << max << endl;
  return 0;
}

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

using std::cerr;
using std::endl;

const int N = 2050;

int n, vis[N], f[N], sum[N], size[N]; char str[N];
std::vector<int> G[N];

void dfs(int x, int fa) {
  int max = 0, pos = 0;
  size[x] = vis[x];
  sum[x] = 0;
  for (int y : G[x]) if (y != fa) {
    dfs(y, x);
    size[x] += size[y];
    sum[x] += sum[y] + size[y];
    if (sum[y] + size[y] > max)
      max = sum[y] + size[y], pos = y;
  }
  if (max * 2 <= sum[x])
    f[x] = sum[x] / 2;
  else
    f[x] = sum[x] - max + std::min(f[pos] * 2, 2 * max - sum[x]) / 2;
}

inline int solve(int rt) {
  dfs(rt, 0);
  int ret = f[rt];
  if (f[rt] * 2 != sum[rt])
    ret = 2e9;
  return ret;
}

int main() {
  scanf("%d %s", &n, str + 1);
  for (int i = 1; i <= n; ++i)
    vis[i] = str[i] - '0';
  for (int i = 1; i < n; ++i) {
    int x, y; scanf("%d %d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  int ans = 2e9;
  for (int i = 1; i <= n; ++i)
    ans = std::min(ans, solve(i));
  if (ans >= 1e9) ans = -1;
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 512
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys

n = ni()
cost =[]
tot = 0
for i in range(n):
    A = lma()
    cost.append(A)
    tot+=sum(A)
nu=[[False]*n for i in range(n)]
for k in range(n):
    for i in range(n):
        if i==k:continue
        for j in range(n):
            if j==k:
                continue
            #print("ijk",i,j,k,"cost",cost[i][j],cost[i][k]+cost[k][j])
            if cost[i][j] >cost[i][k] + cost[k][j]:
                print(-1)
                exit()
            elif cost[i][j]==cost[i][k] + cost[k][j]:

                nu[i][j]=True
#print(nu)
for i in range(n):
    for j in range(n):
        if nu[i][j]:
            tot-=cost[i][j]
print(tot//2)


Measured memory_bytes: 70040
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	if((a==b && a!=c) || (a==c && b!=c) || (b==c && b!=a)) cout << "Yes" << endl;
	else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-06-01 14:51:53
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

#if __cplusplus >= 201703L
template <class Ch, class Tr, class Tuple, std::size_t... Is>
void tuple_out(std::basic_ostream<Ch, Tr>& os, const Tuple& tp, std::index_sequence<Is...>) {
  ((os << (Is ? ", " : "(") << std::get<Is>(tp)), ...) << ")";
}

template <class Ch, class Tr, class... Args>
auto& operator<<(std::basic_ostream<Ch, Tr>& os, const std::tuple<Args...>& tp) {
  tuple_out(os, tp, std::index_sequence_for<Args...>{});
  return os;
}
#endif

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class Compare>
std::ostream& operator<<(std::ostream& os, const std::set<T, Compare>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U, class Compare>
std::ostream& operator<<(std::ostream& os, const std::map<T, U, Compare>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b; cin >> a >> b;
  cout << a * b << endl;

  return 0;
}


Measured memory_bytes: 3500
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1));

ll scoring(vector<ll> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    auto start = chrono::system_clock::now();
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<ll> BestT(d + 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    ll score = scoring(BestT);

    while (1)
    {
        vector<ll> t = BestT;

        int a, b;

        do
        {
            a = rand() % 26 + 1;
            b = rand() % 26 + 1;
        } while (a == b);

        swap(t[a], t[b]);

        if (scoring(t) > score)
        {
            BestT = t;
        }

        auto end = std::chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                      // 要した時間を計算
        auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(dur).count();

        if (msec >= 1900)
        {
            break;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%lld\n", BestT[i]);
    }
}


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

using lint = int64_t;

int main() {
    int a, b, c; lint k;
    cin >> a >> b >> c >> k;

    if (k % 2 == 0) {
        cout << a - b << endl;
    } else {
        cout << b - a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,a,b;
	int c[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	while(1){
	    int count=0,judge=0;
		scanf("%d",&a);
		scanf("%d",&b);
		if(!a)
			break;
		for(i=0;i<a-1;i++)
			count=count+c[i];
		count= count+b;
		judge=count%7;
		switch(judge){
			case 0:
				printf("Wednesday\n");
				break;
			case 1:
				printf("Thursday\n");
				break;
			case 2:
				printf("Friday\n");
				break;
			case 3:
				printf("Saturday\n");
				break;
			case 4:
				printf("Sunday\n");
				break;
			case 5:
				printf("Monday\n");
				break;
			case 6:
				printf("Tuesday\n");
				break;
			default:
			    break;
		}
	}
	return 0;
}

Measured memory_bytes: 584
S = raw_input()
T = raw_input()
list_S = list(S)
list_T = list(T)
ans = False
for i in range(len(list_T)):
        if list_S == list_T:
                ans = True
                break
        X = list_T.pop(0)
        list_T.append(X)
if ans:
        print "Yes"
else:
        print "No"

Measured memory_bytes: 2692
//#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// 基本テンプレート
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<double> vd;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<long, long> pil;


// Effective std
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }

template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }

template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }

template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }

template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }

template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }


// グラフテンプレート
typedef int Weight;

struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) {}
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;


int main() {
  int mtrx[100][100] = {{0}};
  int n, m = 0;
  int v[100] = {0};

  cin >> n >> m;
  rep(i, n) {
    rep(j,m) cin >> mtrx[i][j];
  }
  rep(i, m) cin >> v[i];
  rep(i, n) {
    ll ret = 0;
    rep(j, m) ret += mtrx[i][j] * v[j];
    cout << ret << endl;
  }
  return 0;
}



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

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	int N = Integer.parseInt(br.readLine());
	if (N % 2 == 1)
	    System.out.println((N + 1) / 2);
	else
	    System.out.println(N / 2);
    }
}

Measured memory_bytes: 21588
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>


#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	int n, k, s; cin >> n >> k >> s;

	int f = s + 1;
	if (f == 1000000001) {
		f = 1;
	}
	FOR_LT(i, 0, k) {
		cout << s << " ";
	}
	FOR_LT(j, k, n) {
		cout << f << " ";
	}
	cout << endl;

	return 0;
}

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

enum week {
  MON,
  TUE,
  WED,
  THU,
  FRI,
  SAT,
  SUN
};
int main()
{
 

 
    char s[3];
    // 整数の入力
 
    // 文字列の入力
    scanf("%s",s);
  
 	if(strcmp(s,"SUN")==0){
        printf("7");
    }
if(strcmp(s,"MON")==0){
        printf("6");
}
    if(strcmp(s,"TUE")==0){
        printf("5");
    }
         if(strcmp(s,"WED")==0){
        printf("4");
         }
    if(strcmp(s,"THU")==0){
        printf("3");
    }
  if(strcmp(s,"FRI")==0){
        printf("2");
  }
    if(strcmp(s,"SAT")==0){
        printf("1");
    }
    // 出力
  

    return 0;
}


Measured memory_bytes: 128
import sys
readline = sys.stdin.buffer.readline

N, M = map(int, readline().split())
ans = [0] * (N+1)
graph = [[] for _ in range(N+1)]

for _ in range(M):
    a, b = map(int, readline().split())
    graph[a].append(b)
    graph[b].append(a)

root = 1
q = [root]
checked = [0] * (N + 1)
checked[root] = 1

while q:
    x = q.pop(0)
    for y in graph[x]:
        if checked[y]:
            continue
        ans[y] = x
        checked[y] = 1
        q.append(y)

print('Yes')
print('\n'.join(map(str, ans[2:])))

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

int main() {
	char s[210];
	cin >> s;
	
	for (int i = strlen(s) - 2; i; i -= 2) { //strlenはchar型の文字数
		if (strncmp(s, s + i / 2, i / 2) == 0) { //文字が一致するか
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r=sc.nextInt();
		int d=sc.nextInt();
		long x=sc.nextInt();

		for(int i=0;i<10;i++) {
			x=x*r-d;
			System.out.println(x);
		}
		
		

	}

}

Measured memory_bytes: 21844