akhauriyash/Code-Regression huggingface dataset:
N, K, C = map(int, input().split())
S = input()

L = [0] * K
i = 0
x = 0
while i<K and x<N:
    if S[x] == 'o':
        L[i] = x
        i += 1
        x += C+1
    else:
        x += 1

R = [0] * K
i = K-1
x = N-1
while i>=0 and x>=0:
    if S[x] == 'o':
        R[i] = x
        i -= 1
        x -= C+1
    else:
        x -= 1

ans = []
for i in range(K):
    if L[i] == R[i]:
        ans.append(L[i])
for a in ans:
    print(a+1)


Measured memory_bytes: 22216
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let M: usize = sc.get();
    let Q: usize = sc.get();
    let mut a = vec![vec![0; N]; N];
    for _ in 0..M {
        let mut l: usize = sc.get();
        let mut r: usize = sc.get();
        l -= 1; r -= 1;
        a[l][r] += 1;
    }
    let mut cum = vec![vec![0; N+1]; N+1];
    for i in 0..N {
        for j in 0..N {
            cum[i+1][j+1] = cum[i+1][j] + cum[i][j+1] - cum[i][j] + a[i][j];
        }
    }
    for _ in 0..Q {
        let mut p: usize = sc.get();
        let mut q: usize = sc.get();
        p -= 1; q -= 1;
        println!("{}", cum[q+1][q+1] - cum[p][q+1] - cum[q+1][p] + cum[p][p]);
    }
}


Measured memory_bytes: 7036
#include <cstdio>
int main()
{
	int a, b, c;
	while(~scanf("%d%d%d", &a, &b, &c)) {
		if (c >= a && c <= b) {
			puts("Yes");
		}
		else {
			puts("No");
		}
	}
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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

using namespace std;

int N;
long long int H;
long long int A[100001], B[100001];

long long int solve()
{
    long long int max_A = 0;
    REP(i, N)
        max_A = max(max_A, A[i]);

    sort(B, B+N, greater<long long int>());
    long long int cnt = 0;
    long long int sum_B = 0;
    REP(i, N) {
        if (B[i]>max_A) {
            sum_B += B[i];
            cnt++;
            if (sum_B>=H)
                return cnt;
        }
    }
    return ((H-sum_B+(max_A-1LL))/max_A)+cnt;
}


int main()
{
    scanf("%d %lld", &N, &H);
    REP(i, N)
        scanf("%lld %lld", &A[i], &B[i]);
    cout << solve() << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()
template <typename T>
class FloydWarshall {
  bool _hasNegativeCycle;
  vector<vector<T>> distTo;

 public:
  const static T INF = numeric_limits<T>::max() / 2;
  FloydWarshall(vector<vector<T>> G) {
    int V = G.size();

    distTo.resize(V, vector<T>(V, INF));

    for (int u = 0; u < V; ++u) {
      for (int v = 0; v < V; ++v) {
        if (u == v) {
          distTo[u][v] = 0;
          continue;
        }

        distTo[u][v] = G[u][v];
      }
    }

    for (int w = 0; w < V; ++w) {
      for (int u = 0; u < V; ++u) {
        for (int v = 0; v < V; ++v) {
          distTo[u][v] = min(distTo[u][v], distTo[u][w] + distTo[w][v]);
        }

        if (distTo[u][u] < 0) {
          _hasNegativeCycle = true;
          return;
        }
      }
    }
  }

  bool hasNegativeCycle() { return _hasNegativeCycle; }

  T dist(int s, int t) { return distTo[s][t]; }
};

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

  int V = H * W;
  vector<vector<int>> G(V, vector<int>(V, FloydWarshall<int>::INF));

  vector<string> grid(H);
  rep(i, H) cin >> grid[i];

  auto node = [&](int i, int j) { return i * W + j; };

  auto add = [&](int i, int j, int k, int l) {
    G[node(i, j)][node(k, l)] = 1;
    G[node(k, l)][node(i, j)] = 1;
  };

  rep(i, H) rep(j, W) {
    if (grid[i][j] == '#') continue;

    G[node(i, j)][node(i, j)] = 0;
    if (i - 1 >= 0 && grid[i - 1][j] != '#') add(i, j, i - 1, j);
    if (i + 1 < H && grid[i + 1][j] != '#') add(i, j, i + 1, j);
    if (j - 1 >= 0 && grid[i][j - 1] != '#') add(i, j, i, j - 1);
    if (j + 1 < W && grid[i][j + 1] != '#') add(i, j, i, j + 1);
  }

  FloydWarshall<int> fw(G);
  int ans = 0;
  rep(i, H) rep(j, W) rep(k, H) rep(l, W) {
    int u = node(i, j), v = node(k, l);
    int d = fw.dist(u, v);
    if (d == FloydWarshall<int>::INF) continue;
    ans = max(ans, d);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2176
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<stack>
#include<cstring>
#include<cstdlib>
#include<cmath>

using namespace std;

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

int main(){
	
	int n;
	cin>>n;
	
	rep(t,n){
		double x[4];
		double y[4];
		
		rep(i,4){
			cin>>x[i]>>y[i];
		}
		
		double dx1 = x[0]-x[1];
		double dx2 = x[2]-x[3];
		
		double dy1 = y[0]-y[1];
		double dy2 = y[2]-y[3];
		
		
		if(dx1==0){
			if(dx2==0)puts("YES");
			else puts("NO");
		}else{
			double a1 = dy1/dx1;
			double a2 = dy2/dx2;
			if(fabs(a1-a2)<0.000000001)puts("YES");
			else puts("NO");
		}
	}
}

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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

const int m = 2019;

int main() {
    string S;
    cin >> S;
    int n = S.size();
    reverse(ALL(S));
    int x = 1, total = 0;
    vector<int> cnt(m);
    ll ans = 0;
    REP(i, n) {
        cnt[total]++;
        total += (S[i]-'0')*x;
        total %= m;
        ans += cnt[total];
        x = x*10%m;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3708
import math
n,k = map(int,input().split())
m = min(n, k)
win = 0#負ける確率
for i in range(1, m + 1):
    a = math.ceil(math.log2(k / i)) #a回連続で表で勝利
    win += 1 / n * pow(1 / 2, a) #iが出る確率*a回連続で表の確率
    #print(i, a, 1 / n * pow(1 / 2, a), win)
win += 1 / n * max(0, n - k) #さいころでk以上が出る確率
print(win)


Measured memory_bytes: 3188
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {
	
	
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;

	int ab_x = x2 - x1;
	int ab_y = y2 - y1;

	int ab90_x = ab_y * -1;
	int ab90_y = ab_x;

	cout << ab90_x + x2 << " " << ab90_y + y2 << " " << ab90_x + x1 << " " << ab90_y + y1;



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    int d, r, a, b;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = 1.0000 * a / b;

    cout << d << ' ' << r << ' ' << fixed << setprecision(5) << f << endl;

    return 0;
}


Measured memory_bytes: 3272
def bellman_ford(a, v, e):
    inf = pow(2, 61) - 1
    dist = [inf] * v
    dist[a] = 0
    for i in range(2 * v):
        f = 0
        for s, t, d in E:
            if not dist[s] == inf and dist[t] > dist[s] + d:
                dist[t] = dist[s] + d
                f = 1
        if not f:
            x0 = dist[-1]
            break
        elif f and i == v - 1:
            x0 = dist[-1]
    if x0 == dist[-1]:
        return -dist[-1]
    else:
        return "inf"

n, m = map(int, input().split())
E = []
for _ in range(m):
    a, b, c = map(int, input().split())
    E.append([a - 1, b - 1, -c])
ans = bellman_ford(0, n, m)
print(ans)

Measured memory_bytes: 69912
S = input()
T = input()
ans_list = []
for i in range(len(S)):
    for j in range(i+1,len(S)+1):
        part = S[i:j]
        if len(part) != len(T):
            continue
        for k in range(len(part)):
            if part[k] != T[k] and part[k] != "?":
                break
            elif k == len(part)-1:
                ans_str = S[:i] + T + S[j:]
                ans_str = ans_str.replace("?","a")
                ans_list.append(ans_str)
ans_list.sort()
if ans_list == []:
    print("UNRESTORABLE")
else:
    print(ans_list[0])

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
 
# 入力
N = int(input())
S = str(input())
#A, B, X = map(int, input().split())
h = [0]
h += map(int, S.split())

dp = [0 for _ in range(N+1)]

for i in range(0, N+1) :
  if i == 0 or i == 1:
    dp[i] = 0
  elif i == 2 :
    dp[i] = abs(h[i] - h[i-1])
  else :
    before1 = abs(h[i] - h[i-1]) + dp[i-1]
    before2 = abs(h[i] - h[i-2]) + dp[i-2]
    dp[i] = min(before1, before2)

#print (dp)
print (dp[N])




Measured memory_bytes: 14612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力

            //string[] input = Console.ReadLine().Split(' ');
            //int ans;
            //int A= int.Parse(input[0]);
            //int B= int.Parse(input[1]);

            string S = Console.ReadLine();//整数
            string Sunny;
            string Cloudy;
            string Rainy;

            if (S == "Sunny")
            {
                Console.WriteLine("Cloudy");
            }
            else if (S == "Cloudy")
                Console.WriteLine("Rainy");

            else
            {
                Console.WriteLine("Sunny");
            }
        }
    }

}
    


Measured memory_bytes: 11092
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int M = sc.nextInt();
		SCC scc = new SCC();
		ArrayList<ArrayList<Integer>> parents = new ArrayList<>();
		for (int i = 0; i < N; i++) {
			parents.add(new ArrayList<>());
		}
		for (int i = 0; i < N - 1 + M; i++) {
			int A = Integer.parseInt(sc.next()) - 1;
			int B = Integer.parseInt(sc.next()) - 1;
			scc.addEdge(A, B);
			parents.get(B).add(A);
		}
		scc.calc();
		PrintWriter writer = new PrintWriter(System.out);
		for (int i = 0; i < N; i++) {
			int parent = -1;
			int min = Integer.MAX_VALUE;
			for (int p : parents.get(i)) {
				if (scc.idx[p] < min) {
					min = scc.idx[p];
					parent = p;
				}
			}
			writer.println(parent + 1);
		}
		writer.flush();
	}

	static class SCC {

		int N;
		ArrayList<ArrayList<Integer>> child = new ArrayList<>();
		ArrayList<ArrayList<Integer>> parent = new ArrayList<>();
		int[] idx;

		void addEdge(int from, int to) {
			while (child.size() <= from) {
				child.add(new ArrayList<>());
			}
			while (parent.size() <= to) {
				parent.add(new ArrayList<>());
			}
			child.get(from).add(to);
			parent.get(to).add(from);
		}

		void calc() {
			while (child.size() < parent.size()) {
				child.add(new ArrayList<>());
			}
			while (parent.size() < child.size()) {
				parent.add(new ArrayList<>());
			}
			N = child.size();
			dfs();
		}

		void dfs() {
			idx = new int[N];
			boolean[] used = new boolean[N];
			int pos = 0;
			for (int i = 0; i < N; ++i) {
				if (used[i]) continue;
				used[i] = true;
				ArrayDeque<Integer> q = new ArrayDeque<>();
				q.addAll(child.get(i));
				q.add(-i - 1);
				while (!q.isEmpty()) {
					int cur = q.pollFirst();
					if (cur < 0) {
						idx[-cur - 1] = pos++;
						continue;
					}
					if (used[cur]) continue;
					used[cur] = true;
					q.addFirst(-cur - 1);
					for (int c : child.get(cur)) {
						q.addFirst(c);
					}
				}
			}
		}
	}
}


Measured memory_bytes: 92864
#include<stdio.h>
#define MAX 2001
#define WHITE 0//未訪問
#define GRAY 1//訪問(未確定)
#define BLACK 2//最小値決定済み
#define NIL -1

/*
gcolor[];//color[v]にvへの訪問状態を色で記録
gmatrix[][];//gmatrix[u][v]にuからvへの重みを記録した隣接行列
weight[];//weight[v]にTに属する頂点とV-Tに属する頂点を繋ぐ辺の中で、重みが最小の辺の重みを記録する
parent[];//parent[v]にMSTにおける頂点vの親を記録
*/

int gmatrix[MAX][MAX];

int prim(int n){
  int i,v;
  int u;//頂点
  int minv;//最小の重み
  int weight[MAX];//Tに属する頂点と(V?T)に属する頂点を繋ぐ辺の中で、重みが最小の辺の重みを記録する
  int parent[MAX];//MSTにおける頂点vの親を記録する
  int color[MAX];//訪問状態を記録
  //初期化
  for(i=0; i<n ;++i){
    weight[i] = MAX;
    parent[i] = NIL;
    color[i] = WHITE;
  }
  //初回探索地点をindex0にする
  weight[0] = 0;

  while(1){
    minv = MAX;
    u = NIL;
    //隣接する地点で
    for(i=0; i<n ;++i){
      if(minv > weight[i] && color[i] != BLACK){
	//最小の重みを記録する
	u = i;
	minv = weight[i];
    }
    }
    //全て訪問した
    if(u == NIL) break;
    //訪問済み
    color[u] = BLACK;
    for(v=0; v<n ;++v){
      //uとvの間に辺が存在する
      if(color[v] != BLACK && gmatrix[u][v] != MAX ){
	if(weight[v] > gmatrix[u][v]){
	  //隣接する辺に重みを割り当てる
	  weight[v] = gmatrix[u][v];
	  parent[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum = 0;
  for(i=0;i<n;i++){
    if(parent[i] != NIL) sum += gmatrix[i][parent[i]];
  }

  return sum;
}

int main(){
  int n,i,j;
  scanf("%d",&n);

  for(i=0;i<n;++i){
    for(j=0;j<n;++j){
      int edge;
      scanf("%d",&edge);
      if(edge == NIL) gmatrix[i][j] = MAX;
      else gmatrix[i][j] = edge;
    }
  }

  printf("%d\n",prim(n));

  return 0;
}




Measured memory_bytes: 2152
using System;

class Program {
  static void Main(string[] args) {
    string[] vals = Console.ReadLine().Split();
    int N = int.Parse(vals[0]);
    int Y = int.Parse(vals[1]);

    string ans = "-1 -1 -1";
    for (int i = 0; i <= N; ++i) {
      for (int j = 0; j <= N - i; ++j) {
        if (i * 10000 + j * 5000 + (N - i - j) * 1000 == Y) {
          ans = $"{i} {j} {N - i - j}";
          goto LOOP_END;
        }
      }
    }

  LOOP_END:
    Console.WriteLine(ans);

  }
}


Measured memory_bytes: 13268
#include <iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    int N = S.size(), MOD = 1000000007;
 
    long long dp[100010][4] = {};
    for(int i = N; i >= 0; --i){
        for(int j = 3; j >= 0; --j){
            if(i == N){
                dp[i][j] = (j == 3 ? 1 : 0);
            }else{
                dp[i][j] = dp[i+1][j] * (S[i] == '?' ? 3LL : 1LL);
                if(j < 3 && (S[i] == '?' || S[i] == "ABC"[j])){
                    dp[i][j] += dp[i+1][j+1];
                }
                dp[i][j] %= MOD;
            }
        }
    }
    cout << dp[0][0] << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int tintin=1;
//ちんちんがＫより大きいかどうかで作業を分ける
	for(int i=0;i<n;i++){
		if(tintin<k){
			tintin *=2;
		}
		else if (tintin >=k){
			tintin +=k;
		}
	}
	cout << tintin <<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
bool hikaku(vector<string> MJ){
  int n=MJ.size();
  rep(i,n){
    for(int j=i+1;j<n;j++){
      if(MJ[i]==MJ[j])
        return 1;
    }
  }
  return 0;
}
bool moji(string A,string B){
  if(A[A.size()-1]==B[0])
    return 0;
  return 1;
}
int main() {
  int count=0;
  int N;
  cin>>N;
  vector<string>M(N);
  rep(i,N){
    cin>>M[i];
  }
  if(hikaku(M)){
    cout<<"No";
    return 0;
  }
  rep(i,N-1){
    if(moji(M[i],M[i+1])){
      cout<<"No";
      return 0;
    }
  }
  cout<<"Yes";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    
    int ans=0,sum=0;
    map<int,int> cnt;
    cnt[sum%M]++;
    REP(i,N){
        int a; cin>>a;
        sum+=a;
        ans+=cnt[sum%M];
        cnt[sum%M]++;
    }
    cout<<ans<<endl;
}


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

int main() {
  string s, f, b, rb;
  cin >> s;
  for(int i = 0; i < (s.length() - 1) / 2; i++) {
    f.push_back(s[i]);
    rb.push_back(s[i + (s.length() + 1) / 2]);
  }
  b = rb;
  reverse(rb.begin(), rb.end());
  if(f == b && f == rb)
    printf("Yes\n");
  else
    printf("No\n");
}

Measured memory_bytes: 256
mod=10**9+7
s=input()[::-1]
l=len(s)
dp=[[0]*13 for i in range(l+1)]
dp[0][0]=1
#累乗が大きすぎるので前計算
p=[0]*l
p[0]=1
for i in range(l-1):
    p[i+1]=(p[i]*10)%13
for i in range(l):
    s_sub=s[i]
    if s_sub=="?":
        for j in range(13):
            for k in range(10):
                dp[i+1][(j+k*p[i])%13]+=dp[i][j]
                dp[i+1][(j+k*p[i])%13]%=mod
    else:
        k=int(s_sub)
        for j in range(13):
            dp[i+1][(j+k*p[i])%13]+=dp[i][j]
            dp[i+1][(j+k*p[i])%13]%=mod
print(dp[l][5])

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

int dp[15][2][2][2][2];  // 桁数、smaller、3、5、7
int P[3] = {3, 5, 7};

int main() {
    string N;
    cin >> N;
    vector<int> n;
    for (auto a : N) {
        n.push_back(a - '0');
    }
    int l = n.size();

    rep(i, 12) rep(smaller, 2) rep(x, 2) rep(y, 2) rep(z, 2) dp[i][smaller][x][y][z] = 0;
    dp[0][0][0][0][0] = 1;

    rep(i, l) {
        dp[i+1][1][0][0][0] += (dp[i][0][0][0][0] + dp[i][1][0][0][0]);

        rep(smaller, 2) {
            // if (smaller == 0)
            
            // x = 0の時
            // dp[i+1][smaller][0][0][0] += dp[i][smaller][0][0][0];

            rep(x, 2) rep(y, 2) rep(z, 2) {
                // for (int k = 0; P[k] <= (smaller ? 9 : n[i]); k++) {
                for (int k = 0; k < 3; k++) {
                    if (smaller == 0 && P[k] > n[i]) continue;
                    dp[i+1][smaller || P[k] < n[i]][x || P[k] == 3][y || P[k] == 5][z || P[k] == 7] += dp[i][smaller][x][y][z];
                }
            }
        }
    }

    // rep(i, l) {
    //     printf("dp[%d] = %d\n", i+1, dp[i+1][0][1][1][1] + dp[i+1][1][1][1][1]);
    // }

    cout << dp[l][0][1][1][1] + dp[l][1][1][1][1] << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define BOOST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ll long long
#define test(t) int t ; cin>>t ; while(t--)
ll mulmod(ll a, ll b, ll mod){ll res = 0;a = a % mod;while (b > 0){if (b % 2 == 1)res = (res + a) % mod;a = (a * 2) % mod;b /= 2;}return res % mod;}
int n;
int main(){
    BOOST;
    int a;
    int b;
    cin >> a >> b;
    if(a + b == 15){
        cout << "+";
    }
    else if(a*b == 15){
        cout << "*";
    }else{
        cout << "x";
    }
    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    s[k - 1] = s[k - 1] + 0x20;
    
    cout << s << endl;
    return 0;
}

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

using pint = pair<int, int>;

int N;
vector<vector<pint>> v;

bool judge(int bit) {
  for (int i = 0; i < N; i++) {
    if (!(bit & (1 << i))) continue;

    for (pint xy : v[i]) {
      int x = xy.first;
      int y = xy.second;
      if (y == 1 && !(bit & (1 << x))) return false;
      if (y == 0 && (bit & (1 << x))) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  v.resize(N);
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    v[i].resize(A);
    for (int j = 0; j < A; j++) {
      cin >> v[i][j].first >> v[i][j].second;
      --v[i][j].first;
    }
  }

  int res = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    if (judge(bit)) {
      int count = 0;
      for (int i = 0; i < N; i++) {
        if (bit & (1 << i)) count++;
      }
      res = max(res, count);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 3620
function main(input) {
  input = input.trim().split("\n");
  const [n, k] = input[0].split(" ").map(n => Number(n));
  const a = input[1].split(" ").map(n => Number(n));
  const map = {};
  a.forEach(num => {
    if (!map[num]) {
      map[num] = 1;
    } else {
      map[num] = map[num] + 1;
    }
  });
    const arr = Object.keys(map).map(key => ({ key, value: map[key] }));
    arr.sort((a, b) => b.value - a.value);
  const slicedArr = arr.slice(0, k);
  let result = n;
  for (const object of slicedArr) {
  	result -= object.value;
  }
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 52000
loop do
  a = gets.split.map(&:to_i)
  ans = ""
  break if a[0] == 0 && a[1] == 0
  for i in 0...a[1] do
    ans << "#"
  end
  puts ans
  ans = ""
  ans << "#"
  for i in 2...a[1] do
    ans << "."
  end
  ans << "#"
  for j in 2...a[0] do
    puts ans
  end
  ans = ""
  for i in 0...a[1] do
    ans << "#"
  end
  puts ans
  puts ""
end

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

int main() {
  string N;
  cin>>N;
  if(N[0]=='7'||N[1]=='7'||N[2]=='7'){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  

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

struct Node{
	int key;
	Node *parent;
	Node *left;
	Node *right;
	
	Node(): left(NULL), right(NULL){}
	Node(int _k): key(_k), left(NULL), right(NULL){}
};

void Insert(Node *&T, int key)
{
	Node *z = new Node(key);
	
	Node *y = NULL;
	Node *x = T;

	while(x != NULL)
	{
		y = x;
		if (z->key < x->key)
		{
			x = x->left;
		}
		else
		{
			x = x->right;
		}
	}
	
	z->parent = y;
	 
	if (y == NULL)
	{
		T = z;
	}
	else if (z->key < y->key)
	{
		y->left = z;
	}
	else
	{
		y->right = z;
	}
}

void Preorder(Node *T)
{
	if (T == NULL) return;
	
	cout << " " << T->key;
	Preorder(T->left);
	Preorder(T->right);
}

void Inorder(Node *T)
{
	if (T == NULL) return;
	
	Inorder(T->left);
	cout << " " << T->key;
	Inorder(T->right);
}

int main ()
{
	int n;
	cin >> n;
	string cmd;
	Node *Tree = NULL;
	while(n--)
	{
		cin >> cmd;
		if (cmd == "insert")
		{
			int k;
			cin >> k;
			Insert(Tree, k);
		}
		else if (cmd == "print")
		{
			Inorder(Tree);
			cout << endl;
			Preorder(Tree);
			cout << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 26460
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

string pat = "RGY";
vector<int> rec[3], pre[3][3];

int solve(int c, int len, int cnt) {
  int ub = cnt, lb = -1;
  while(ub - lb > 1) {
    int mid = (ub + lb) / 2;
    // fprintf(stderr, "mid = %d, size = %zu\n", mid, rec[c].size());
    if(rec[c][mid] < len) {
      lb = mid;
    }
    else {
      ub = mid;
    }
  }
  return cnt - ub;
}

const int INF = 1 << 28;
int dp[3][410][410][4];
int main() {
  int N; string s;
  cin >> N >> s;

  int cnt[3] = {};
  for(int i=0; i<N; i++) {
    int c = pat.find(s[i]);
    rec[c].emplace_back(i);
    for(int k=0; k<3; k++) {
      pre[c][k].emplace_back(cnt[k]);
    }
    cnt[c]++;
  }

  fill(dp[0][0][0], dp[2][0][0], INF);
  dp[0][0][0][0] = 0;
  
  for(int i=0; i<N; i++) {
    int cur = i % 2, nxt = 1 - cur;
    for(int R=0; R<=min<int>(i, rec[0].size()); R++) {
      for(int G=0; R+G<=i and G<=min<int>(i, rec[1].size()); G++) {
        for(int z=0; z<4; z++) {
          int Y = i - R - G;
          if(Y > rec[2].size() or dp[cur][R][G][z] == INF) {
            dp[cur][R][G][z] = INF;
            continue;
          }
          // fprintf(stderr, "dp[%d][%d][%d][%d][pre = %d] = %d\n", i, R, G, Y, z, dp[cur][R][G][z]);
          int idx = R + G + Y;

          /*
          p[0] = solve(0, i, R);
          p[1] = solve(1, i, G);
          p[2] = solve(2, i, Y);
          fprintf(stderr, "i = %d, R = %d, G = %d, Y = %d, ans = (%d, %d, %d)\n", i, R, G, Y, p[0], p[1], p[2]);
          */

          if(R + 1 <= rec[0].size() and z != 1) {
            int sum = 0;
            sum += max(0, R - pre[0][0][R]);
            sum += max(0, G - pre[0][1][R]);
            sum += max(0, Y - pre[0][2][R]);
            // fprintf(stderr, "place R: sum = %d\n", sum);

            int dist = rec[0][R] + sum - idx;
            dp[nxt][R+1][G][1] = min(dp[nxt][R+1][G][1], dp[cur][R][G][z] + dist);
          }
          if(G + 1 <= rec[1].size() and z != 2) {
            int sum = 0;
            sum += max(0, R - pre[1][0][G]);
            sum += max(0, G - pre[1][1][G]);
            sum += max(0, Y - pre[1][2][G]);

            int dist = rec[1][G] + sum - idx;
            dp[nxt][R][G+1][2] = min(dp[nxt][R][G+1][2], dp[cur][R][G][z] + dist);
          }
          if(Y + 1 <= rec[2].size() and z != 3) {
            int sum = 0;
            sum += max(0, R - pre[2][0][Y]);
            sum += max(0, G - pre[2][1][Y]);
            sum += max(0, Y - pre[2][2][Y]);

            //            fprintf(stderr, "pre: %d, %d, %d\n", pre[2][0][Y], pre[2][1][Y], pre[2][2][Y]);

            int dist = rec[2][Y] + sum - idx;
            //fprintf(stderr, "dist = %d, rec = %d, sum = %d, idx = %d\n", dist, rec[2][Y], sum, idx);
            dp[nxt][R][G][3] = min(dp[nxt][R][G][3], dp[cur][R][G][z] + dist);
          }
          dp[cur][R][G][z] = INF;
        }
      }
    }
  }

  int A = rec[0].size(), B = rec[1].size();
  int ans = INF;
  for(int k=0; k<4; k++) ans = min(ans, dp[N%2][A][B][k]);
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}



Measured memory_bytes: 8484
# 2019/08/06

x1,y1,x2,y2=map(int,input().split())

xx=x2-x1
yy=y2-y1

x3=x2-yy
y3=y2+xx
x4=x1-yy
y4=y1+xx
print(x3,y3,x4,y4)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int Search( int, int );

int n, *A;

int main()
{
  int i, j, q, result, *m;

  scanf("%d", &n);
  A = malloc( n * sizeof(int));
  for( i=0; i<n; i++ ) scanf("%d", &A[i]);

  scanf("%d", &q);
  m = malloc( q * sizeof(int));
  for( i=0; i<q; i++ ) scanf("%d", &m[i]);
  
  for( i=0; i<q; i++ )
    {
      result = Search( 0, m[i] );

      if( result == 1 ) printf("yes\n");
      else if( result == 0 ) printf("no\n");
    }

  return 0;
}


int Search( int i, int m )
{
  int res;

  if( m == 0 ) return 1;
  if( i >= n ) return 0;

  res = Search( i + 1, m ) || Search( i + 1, m - A[i] );

  return res;
}



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

int main(){
  int h,w;
  cin>>h>>w;
  int a[h][w];
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      a[i][j] = 0;
  int h1,w1;
  cin>>h1>>w1;
  for(int i=0;i<h1;i++)
    for(int j=0;j<w;j++)
      a[i][j] = 1;
  for(int j=0;j<w1;j++)
    for(int i=0;i<h;i++)
      a[i][j] = 1;
  int c = 0;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(a[i][j] == 0)
        c++;
  cout<<c<<endl;
  return 0;
}

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

const int MOD = 2019;

int main() {
    int L, R;
    cin >> L >> R;

    map<int, int> bucket;
    for (int i = 0; i <= MOD; ++i) {
        if (L + i > R) break;

        int t = (L + i) % MOD;
        if (bucket.count(t) == 0) bucket[t] = 1;
    }

    int ans = MOD;
    for (auto i = bucket.begin(); i != bucket.end(); ++i) {
        for (auto j = bucket.begin(); j != bucket.end(); ++j) {

            if (i != j) {
                ans = min(ans, i->first * j->first % MOD);
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(void){
	int c1,c2,c3,sum;	//c1,c2=自分のカード c3=相手のカード
	int i,cnt=0;

	while(cin>>c1>>c2>>c3){
		sum=c1+c2;
		for(i=1;i<=10;i++){
			if(i!=c1 && i!=c2 && i!=c3){
				if(sum+i<=20)	cnt++;
			}
		}
		if(cnt>=4)	cout<<"YES"<<endl;
		else	cout<<"NO"<<endl;
		cnt=0;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int cnt = 0;
		for(int i = a; i <= b; i++) {
			int v1 = i % 10;//一の位
			int v2 = i / 10 % 10;//十の位
			int v3 = i / 1000 % 10;//千くらい
			int v4 = i / 10000 % 10;//万の位
			if(v1 == v4 && v2 == v3) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  string path;
  cin >> path;
  int m = path.size();
  int n=0;
  int s=0;
  int e=0;
  int w=0;
  for(int i=0; i<m; i++) {
    switch(path.at(i)) {
      case 'N':
        n++;
        break;
      case 'S':
        s++;
        break;
      case 'E':
        e++;
        break;
      case 'W':
        w++;
        break;
    }
  }
  if(n>0 && s>0 && e>0 && w>0) {
    cout << "Yes" << endl;
  } else if(n==0 && s==0 && e*w!=0) {
    cout << "Yes" << endl;
  } else if(e==0 && w==0 && n*s!=0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
"use strict";

var main = function main(input) {
  var args = input.split('\n');
  var N = parseInt(args[0], 10);
  var a = [];

  for (var i = 1; i <= N; i++) {
    a.push(parseInt(args[i], 10));
  }

  var next = a[0];
  var flag = false;
  var count = 0;

  for (var _i = 0; _i < N; _i++) {
    count++;

    if (next == 2) {
      flag = true;
      break;
    }

    next = a[next - 1];
  }

  if (flag) {
    console.log(count);
  } else {
    console.log(-1);
  }
};

main(require('fs').readFileSync('/dev/stdin', 'utf-8'));

Measured memory_bytes: 27084
ans = 1000
ans_f = 0
a,b = map(int,input().split())
for i in range(a):
    c,d = map(int,input().split())
    if d <= b:
        ans_f = 1
        if c < ans:
            ans = c
if ans_f == 1:
    print(ans)
else:
    print('TLE')

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()

ll inq(ll x, ll y)
{
    if (!y) return 1;
    ll l = inq(x, y / 2);
    if (y % 2) return l * l * x;
    return l * l;
}

signed main()
{
    ll n, c;
    cin >> n >> c;
    vector<ll> Len(n), p(n - 1);
    forn(i, n) cin >> Len[i], Len[i] *= n;
    sort(all(Len));
    c *= n;
    iota(all(p), 0);
    ll good = 0, all_ways = 0, W = Len[n - 1], k = (1 << (n - 1)), we, le, m2, wc;
    while (1)
    {
        all_ways += inq(c / n, n - 1);
        vector<vector<ll> > dp(c + 1, vector<ll>(k));
        dp[W][0] = 1;
        forn(i, c)
        {
            if (i % n == 0) continue;
            we = p[i % n - 1];
            le = Len[we];
            forn(mask, k)
            {
                if ((1 << we) & mask) continue;
                m2 = mask + (1 << we);
                for (ll ac = i; ac <= c; ac++)
                {
                    wc = max(ac, min(c, le + i));
                    dp[wc][m2] += dp[ac][mask];
                }
            }
        }
        good += dp[c][k - 1];
        if (!next_permutation(all(p)))
        {
            printf("%.15f", (double)good / all_ways);
            return 0;
        }
    }
}


Measured memory_bytes: 384
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn main(){
    let s = read_as_string();

    println!("{}", &s[0..s.len()-8]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
std::vector<int > temp;
std::vector<long long > ans;

void dfs(std::vector<int > vec, bool free){
  //printf("dfs called (size=%d)\n", vec.size());
  if (vec.size()==10){
  //if (vec.size()==2){
    //std::reverse(vec.begin(), vec.end());
    long long value = 0;
    for (int i=0; i<vec.size(); i++){
      //printf("vec[%d]=%d\n",i,vec[i]);
      value += pow(10,vec.size()-i-1)*vec[i];
    }
    //printf("value=%lld\n", value);
    ans.push_back(value);    
  } else {
    if (free){
      for (int j=0; j<10; j++){
        std::vector<int> vec2(vec.size());
        std::copy(vec.begin(), vec.end(), vec2.begin());
        vec2.push_back(j);
        //printf("size=%d, pushing %d\n", vec.size(), j);
        dfs(vec2, (j==0)?true:false);
      }
    } else {
      for (int j=std::max(vec[vec.size()-1]-1, 0); j<=std::min(vec[vec.size()-1]+1,9); j++){
        std::vector<int> vec2(vec.size());
        std::copy(vec.begin(), vec.end(), vec2.begin());
        vec2.push_back(j);
        //printf("push %d\n", j);
        dfs(vec2, false);
      }
    }
  }
  return;
}

int main(){
  int K;
  scanf("%d", &K);
  dfs(temp, true);
  std::sort(ans.begin(), ans.end());
  printf("%lld\n", ans[K]);
  return 0;
}


Measured memory_bytes: 3052
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class B
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<int>();
            var L = Console.ReadLine().Trim().Split(' ').Select(long.Parse).ToArray();
            if (L.Length < 3)
            {
                Console.WriteLine(0);
                return;
            }

            var answer = 0;
            for (var i = 0; i < L.Length; i++)
            {
                for (var j = i + 1; j < L.Length; j++)
                {
                    for (var k = j + 1; k < L.Length; k++)
                    {
                        if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
                        if (L[i] + L[j] > L[k] && L[i] + L[k] > L[j] && L[j] + L[k] > L[i]) answer++;
                    }
                }
            }
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
        }
    }
}


Measured memory_bytes: 28436
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;

vector<int>v[100001];
int depth1[100001];
int depth2[100001];
void dfs(int k,int x,int depth[],int sum){
    depth[k]=sum;
    for(auto &e:v[k]){
        if(e==x)continue;
        dfs(e,k,depth,sum+1);
    }
}
int main(){
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        v[a-1].push_back(b-1);
        v[b-1].push_back(a-1);
    }
    dfs(n-1,-1,depth1,0);//sunuke
    dfs(0,-1,depth2,0);//fenec
    int fennec=0,snuke=0;
    for (int i=0; i<n; i++) {
        int a=depth1[i],b=depth2[i];
        if(a>=b)fennec++;
        else snuke++;
    }
    if(fennec>snuke)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    }

Measured memory_bytes: 12800
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define sort(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	deque<int> data;
	ff(i, 1, n+1) {
		int a;
		cin >> a;
		ff(j, 0, a) {
			data.push_back(i);
		}
	}
	ff(y, 0, h) {
		vector<int> line(w);
		ff(x, 0, w) {
			if (y % 2 == 1) {
				line.at(w - 1 - x) = data.front();
			}
			else {
				line.at(x) = data.front();
			}
			data.pop_front();
		}
		cout << line.at(0);
		ff(k, 1, w) {
			cout << " " << line.at(k);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{

    int N;
    cin >> N;
    vector<int>L(N);
    for (int i = 0; i < N; i++)
        cin >> L[i];

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

    int now = 0;
    for (int i = 0; i < N - 1; i++)
        now += L[i];

    now > L[L.size() - 1] ? cout << "Yes" : cout << "No";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
k = int(input())
count = 0
for i in range(1, k+1):
    for j in range(i+1, k+1):
        if (i % 2 == 0 and j % 2 != 0) or (i % 2 != 0 and j % 2 == 0) :
            count += 1
print(count)

Measured memory_bytes: 2940
#include <string.h>
#include <algorithm>
#include <queue>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;
typedef long long int ll;
int pos = 1;
void change()
{
    const string path = "C:\\Users\\www34\\Desktop\\data_oi\\temp";
    string p, o;
    if (pos < 10)
    {
        p = path + "\\" + (char)(pos + '0') + ".in";
        o = path + "\\" + (char)(pos + '0') + ".out";
    }
    else
    {
        p = path + "\\" + "10" + ".in";
        o = path + "\\" + "10" + ".out";
    }
    pos++;
    freopen(&p[0], "r", stdin);
    //  freopen(&o[0], "w", stdout);
}
ll x[200000 + 10];
int main()
{
    int t = 1;
    while (t--)
    {
        //   change();
        int n, k;
        cin >> n >> k;
        for (int i = 1; i <= n; i++)
            cin >> x[i];
        sort(x + 1, x + 1 + n);
        ll ans = 0;
        for (int i = 1; i + k - 1 < n; i++)
            ans += x[i];
        cout << ans;
    }
    return 0;
}
/*
3
3 2 1
1 2 3 
*/

Measured memory_bytes: 2424
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vint x(n);
	fori(n) cin >> x[i];
	ll ans = LLONG_MAX;
	for(int i = 1; i <= 100; i++) {
		ll cur = 0;
		forj(n) cur += (x[j] - i)*(x[j] - i);
		ans = min(ans, cur);
	}
	cout << ans << nl;
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N = int(input())
A = [[x-1 for x in list(map(int, input().split()))[::-1]] for _ in range(N)]

def can_match(i, A, next_set):
  if not A[i]:
    return
  j = A[i][-1]
  if A[j][-1] == i:
    if i < j:
      next_set.add((i,j))
    else:
      next_set.add((j,i))
      
next_set = set()
for i in range(N):
  can_match(i, A, next_set)
  
day = 0
battle = 0
while next_set:
  day += 1
  current_set, next_set = next_set, set()
  for match in current_set:
    battle += 1
    del A[match[0]][-1]
    can_match(match[0], A, next_set)
    del A[match[1]][-1]
    can_match(match[1], A, next_set)
    
if battle == N*(N-1)//2:
  print(day)
else:
  print(-1)

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int Len[55], Pat[55];

int rec(int level, int layer) {
  // バーガー全部
  if (layer == Len[level]) return Pat[level];

  int ans = 0;

  // 下のバン
  layer--;

  // 下のk-1バーガー
  if (layer > 0) {
    int len = min(layer, Len[level-1]); // これ良くわからん
    ans += rec(level-1, len);
    layer -= len;
  }

  // 真ん中のパティ
  if (layer > 0) {
    ans++;
    layer--;
  }

  // 上のk-1バーガー
  if (layer > 0) {
    int len = min(layer, Len[level-1]);
    ans += rec(level-1, len);
    layer -= len;
  }

  return ans;
}

signed main() {
   int N, X;
   cin >> N >> X;

   Len[0] = Pat[0] = 1;
   for (int i = 1; i <= N; i++) {
      Len[i] = Len[i-1] * 2 + 3;
      Pat[i] = Pat[i-1] * 2 + 1;
   }

   cout << rec(N, X) << endl;

   return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.OptionalInt;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int A = Integer.parseInt(in.next());
            int B = Integer.parseInt(in.next());
            int M = Integer.parseInt(in.next());
            int a[] = new int[A];
            int b[] = new int[B];
            for (int i = 0; i < A; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < B; i++) {
                b[i] = Integer.parseInt(in.next());
            }
            long ans = Arrays.stream(a).min().getAsInt() + Arrays.stream(b).min().getAsInt();

            for (int i = 0; i < M; i++) {
                int x = Integer.parseInt(in.next()) - 1;
                int y = Integer.parseInt(in.next()) - 1;
                int c = Integer.parseInt(in.next());
                ans = Math.min(ans, a[x] + b[y] - c);
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 66448
#include <iostream>
#include <stdio.h>

using namespace std;

int main(){

	int stu[51];
	double w,h;
	double BMI;
	double BMIs[51] = {0};

	for(int i = 0; i < 50; i++){
		
		scanf("%d,%lf,%lf" , &stu[i] , &w , &h);
		if(stu[i] == 0) break;

		BMI = w / (h * h);

		if(BMI >= 25){
			BMIs[i] = stu[i];
		}
	}

	for(int i = 0; i < 50; i++){
		if(BMIs[i] != 0){
			cout << BMIs[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if (true)
#define dvout(v) vout(v)
#else
#define dout   \
	if (false) \
	cout
#define debug() if (false)
#define dvout if(false);
#endif //
#define next asdnext
#define prev asdprev
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define vrep(i, v) for (auto &i : v)
#define all(x) (x).begin(), (x).end()
#define vout(v)           \
	for (auto &i : v)     \
	{                     \
		cout << i << " "; \
	}                     \
	cout << "\n"; //配列出力
#define vin(v)        \
	for (auto &i : v) \
		cin >> i; //配列入力
#define vecin(v,n)	\
	vec(v,n);		\
	vin(v);
#define vec(v, n) vector<int> v(n, 0);
#define mod (int)(1e9+7)
typedef long long ll;
typedef unsigned long long ull;
void Main()
{
	int N;
	cin>>N;
	vec(a,N);
	vin(a);

	dvout(a);

	double ans=0;
	rep(i,N){
		ans += 1.0/a[i];
	}
	ans = 1/ans;

	cout<<ans<<endl;
}
 
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256