akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {
  private static int solve(int x) {
    int sum = 0;
    for (int i = 1; true; i++) {
      sum += i;
      if (x <= sum) {
        return i;
      }
    }
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int x = reader.nextInt();
    out.println(solve(x));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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

int comb(int x, int y, int z) {
    if(x == y && y == z && z == x) {
        return 1;
    } else if(x != y && y != z && z != x) {
        return 6;
    } else {
        return 3;
    }
}

int calc(int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

int fanc(int i) {
    int count = 0;
    int limit = sqrt(i);

    for(int x = 1; x <= limit; ++x) {
        for(int y = x; y <= limit; ++y) {
            // x,yだけで超えてれば次のyはやらない
            if(calc(x, y, 1) > i) {
                break;
            }

            for(int z = y; z <= limit; ++z) {
                // iを超えたらzのループから抜ける
                if(calc(x, y, z) > i) {
                    break;
                }
                if(calc(x, y, z) == i) {
                    count += comb(x, y, z);
                }
            }
        }
    }

    return count;
}

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

    vector<int> ans;
    for(int i = 1; i <= n; ++i) {
        ans.push_back(fanc(i));
    }

    rep(i, n) { cout << ans[i] << endl; }
}

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

int main() {
  int N;
  cin >> N;
  string S;
  vector<int> cases(4);
  for (int i = 0; i < N; i++){
    cin >> S;
    if (S == "AC") cases[0]++;
    else if (S == "WA") cases[1]++;
    else if (S == "TLE") cases[2]++;
    else cases[3]++;
  }
  cout << "AC x " << cases[0] << endl;
  cout << "WA x " << cases[1] << endl;
  cout << "TLE x " << cases[2] << endl;
  cout << "RE x " << cases[3] << endl;
}


Measured memory_bytes: 3628
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    a, b, c = map(int, readline().split())

    if a + b == c or a + c == b or b + c == a:
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    d = {"Sunny":1 , "Cloudy":2, "Rainy":0}
    a = ["Sunny", "Cloudy", "Rainy"]
    print(a[d[input().rstrip()]])
    return

#B
def B():
    s = S()
    for i, si in enumerate(s):
        if i % 2:
            if si == "R":
                print("No")
                return
        else:
            if si == "L":
                print("No")
                return
    print("Yes")
    return

#C
def C():
    n, k, q = LI()
    d = [0] * n
    for _ in range(q):
        a = II() - 1
        d[a] += 1
    for a in d:
        if k - (q - a) > 0:
            print("Yes")
        else:
            print("No")
    return

#D
def D():
    n,m = LI()
    a = LI()
    q = []
    for ai in a:
        heappush(q, -ai)
    for _ in range(m):
        heappush(q, heappop(q) / 2)
    ans = 0
    while q:
        ans += int(-heappop(q))
    print(ans)
    return

#E
def E():
    s = S()
    t = S()
    d = defaultdict(list)
    for i,si in enumerate(s):
        d[si].append(i)
    if d[t[0]] == []:
        print(-1)
        return
    before = d[t[0]][0]
    ans = 0
    for ti in t[1:]:
        if d[ti] == []:
            print(-1)
            return
        a = d[ti]
        index = bisect_right(a, before)
        if index == len(a):
            ans += 1
            before = a[0]
        else:
            before = a[index]
    print(ans * len(s) + before + 1)
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    E()


Measured memory_bytes: 59888
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, x, y, b, p;

int main(){
	cin >> n;
	REP(i, n){
		cin >> x >> y >> b >> p;
		int money = x*b + y*p;
		if (b >= 5 && p >= 2){
			cout << money * 8 / 10 << endl;
		}
		else{
			int money2 = (x*max(b, 5) + y*max(p, 2)) * 8 / 10;
			if (money <= money2){
				cout << money << endl;
			}
			else{
				cout << money2 << endl;
			}
		}
	}
}

Measured memory_bytes: 1160
use std::io;
use std::cmp;


// read a line(without line feed)
fn read_line() -> String {
    let mut in_str = String::new();
    io::stdin().read_line(&mut in_str).unwrap();
    return in_str.trim().to_string();
}

// read wods on a line
pub fn read_words_in_line() -> Vec<String> {
    let s = read_line();
    return s.split_whitespace().map(|x| x.to_string()).collect::<Vec<String>>()
}

// read type t on a line
pub fn read_t_in_line<T : std::str::FromStr>() -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for e in read_words_in_line().iter().map(|x| x.parse::<T>()) {
        if let Ok(r) = e {
            v.push(r);
        }
        else{
            return Vec::new();
        }
    }
    return v;
}

// sort slice
pub fn sort<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort();
}
// sort slice by reverse order
pub fn sort_rev<T : std::cmp::Ord>(slice : &mut [T]) {
    slice.sort_by(|x, y| y.cmp(x));
}

pub fn min<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::min(a, b);
}

pub fn max<T : std::cmp::Ord>(a : T, b : T) -> T{
    return cmp::max(a, b);
}


fn main() {
    let v1 = read_t_in_line::<i32>();
    let (n, m, c) = (v1[0], v1[1], v1[2]);
    let b = read_t_in_line::<i32>();
    let mut ans = 0;
    for _ in 0..n {
        let v = read_t_in_line::<i32>();
        let mut sum = c;
        for j in 0..m {
            sum += v[j as usize] * b[j as usize]
        }
        if sum > 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	char arr[101] = {0};
	scanf("%s",arr);
	int a=0;
	while(1) {
		//cout << arr[a] << endl; 
		if(arr[a]=='\0') {
			break;
		}
		a++;
	}
	//cout << a;
	int b=0, flag = 0;
	for(int i=0; i<a; i++) {
		if(arr[i]=='C') {
			b=i;
			flag = 1;
			break;
		}
	}
	for(int i=b; i<a; i++) {
		if(arr[i]=='F' && flag == 1) {
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

int main() {
    int n, m;
    cin >> n >>m;
    vector<pair<int, int>> ans;
    if (n % 2) {
        for (int l = 1, r = n-1; l < r; l++, r--) {
            ans.emplace_back(l, r);
        }
    } else {
        bool flag = false;
        for (int l = 1, r = n-1; l < r; l++, r--) {
            if (!flag && r - l <= n/2) {
                --r;
                flag = true;
            }
            ans.emplace_back(l, r);

        }
    }
    rep(i, m) {
        printf("%d %d\n", ans[i].first, ans[i].second);
    }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

void solve(){
    string s;
    cin >> s;

    int ans=0;
    for (int i = 0; i < 6; i++) {
        if (s[i] == '1') {
            ans++;
        }
    }
    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static final long MOD = 1000000007;
	static long solve(long N , long K){
		long ret = 0;
		for(long k = K ; k <= N + 1 ; ++k){
			long low = k * (k - 1) / 2;
			long high = k * (2 * N - k + 1) / 2;
			ret = (ret + high - low + 1) % MOD;
//			System.out.println(high+" "+low);
		}
		return ret;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		System.out.println(solve(N , K));
	}
}


Measured memory_bytes: 35600
from collections import deque

H, W = map(int, input().split())
S = [input() for _ in range(H)]

c = [[-1 for _ in range(W)] for _ in range(H)]
d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
q = deque()
q.append((0, 0))
c[0][0] = 1

while q:
    x, y = q.popleft()
    for dx, dy in d:
        nx = x + dx
        ny = y + dy
        if nx < 0 or nx >= W or ny < 0 or ny >= H:
            continue
        if S[ny][nx] == "." and c[ny][nx] is -1:
            c[ny][nx] = c[y][x] + 1
            q.append((nx, ny))

c_min = c[H - 1][W - 1]

if c_min == -1:
    ans = -1
else:
    ans = sum([s.count(".") for s in S]) - c_min

print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  ll l,t;
  cin >> n >> l >> t;
  ll x[n];int w[n];
  rep(i,n)cin >> x[i] >> w[i];
  int p[n];
  rep(i,n){
    if(w[i]==1)p[i]=(x[i]+t)%l;
    else p[i]=((x[i]-t)%l+l)%l;
  }
  int id=-1;
  int p0=p[0];
  sort(p,p+n);
  if(w[0]==1){
    rep(i,n)if(p[i]==p0)id=i;
  }else{
    rep(i,n)if(p[n-1-i]==p0)id=n-1-i;
  }
  auto calc_count = [&] (ll dif){
    if(t*2 < dif) return 0LL;
    ll remain = t*2 - dif;
    return 1+remain/l;
  };
  ll c = 0;
  for(int i=1;i<n;i++){
    if(w[0]==1){
      if(w[i]==2)c+=calc_count(x[i]-x[0]);
    }
    if(w[0]==2){
      if(w[i]==1)c-=calc_count(x[0]+l-x[i]);
    }
  }
  int res[n];
  rep(i,n)res[i]=p[((i+id-c)%n+n)%n];
  rep(i,n)cout << res[i] << endl;
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
struct Res{
  int time;
  int channel;
  int judge;
};
int comp(Res G,Res H){
  if(G.time<H.time) return 1;
  if(G.time>H.time) return 0;
  return G.judge<H.judge;

}
int main(){
  int n,C,s[20000],t[200000],c[200000],a=0,m=0;
  cin>>n>>C;
  vector<Res> A;
  rep(i,n) cin>>s[i]>>t[i]>>c[i],A.push_back({s[i],c[i],1}),A.push_back({t[i]+1,c[i],-1});
  set<int> B;
  int num[31]={0};
  sort(A.begin(),A.end(),comp);
  rep(i,A[2*n-1].time+1){
    while(A[a].time==i){
      if(A[a].judge==1){
        num[A[a].channel]++;
        B.insert(A[a].channel);
      }
      else{
        num[A[a].channel]--;
        if(num[A[a].channel]==0) B.erase(A[a].channel);
      }
      a++;
    }
    m=max(m,int(B.size()));
  }
  cout<<m;
}

Measured memory_bytes: 5492
#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()

    ans = 0

    for i in range(len(s)//2):
        if s[i] != s[len(s)-i-1]:
            ans += 1

    print(ans)






if __name__ == '__main__':
    main()


Measured memory_bytes: 3564
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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


int main() {
    int N;
    cin >> N;
    vector<uint64_t> C(N);
    vector<uint64_t> S(N);
    vector<uint64_t> F(N);
    rep(i, N-1) {
        cin >> C[i];
        cin >> S[i];
        cin >> F[i];
    }
    S[N-1] = 0;

    rep(i, N-1) {
        uint64_t arrive = 0;
        for(int j=i+1; j<N; ++j) {
            auto start = max(arrive, S[j-1]);
            start = ((start + F[j-1]-1) / F[j-1]) * F[j-1]; 
            arrive = start + C[j-1];
//            cout << "  N: " << j << "begin:" << start << " arrive " << arrive << endl;
        }
        cout << arrive << endl;
    }
    cout << 0 << endl;

    return 0;
}



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

int main() {
    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    vector<vector<ll>> dp(N+1, vector<ll>(2));
    dp[0][0] = 1;
    rep(i, 0, N) {
        if(A[i]%2) {
            dp[i+1][0] += dp[i][0];
            dp[i+1][0] += dp[i][1];
            dp[i+1][1] += dp[i][1];
            dp[i+1][1] += dp[i][0];
        } else {
            dp[i+1][0] = dp[i][0] * 2;
            dp[i+1][1] = dp[i][1] * 2;
        }
    }
    cout << dp[N][P] << endl;
    return 0;
}


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

int main(){
    int N, D, X;
    cin >> N >> D >> X;
    int a[110];
    for(int i=0;i<N;i++)
        cin >> a[i];
    
    int sum = 0;
    for(int i=0;i<N;i++){
        for(int j=0;(j*a[i]+1)<=D;j++){
            sum++;
        }
    }
    cout << sum + X << '\n';
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = input()
if N == 1:
    print("No")
    exit()

for i in range(1,N):
    s1 = S[:i]
    s2 = S[i:]
    if s1 == s2 and len(s1)*2 == N:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main()
  {
  int n,c=0,i;
  cin>>n;
  char a[n];
    for(int i=0;i<n;i++)
      {
      cin>>a[i];
      }
    
    for(int i=0;i<n;i++)
      {
      if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
        c++;
      }
  cout<<c<<endl;
  
  return 0;
  }

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

int main() {
  int S,T;
  cin >>S>>T;
  
  if (T == 1)
  cout << 0 << endl;
  else{
 int A = S-1;
 int B = T-1;
 
  cout << (A+B-1)/A << endl;
     }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#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;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >> s;
    string t; cin >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<int>());

    if (s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    } 
    return 0;
}



Measured memory_bytes: 256
def main():
    n, m = map(int, input().split())

    dic = dict()
    for i in range(m):
        p, y = map(int, input().split())
        if p not in dic:
            dic[p] = list()
        dic[p].append([y,i])

    for v in dic.values():
        v.sort(key=lambda x:x[0])

    l = [0 for i in range(m)]
    last_k = n+1
    for k, v in dic.items():
        if k != last_k:
            j = 1
        for V in v:
            P = str(k)
            O = str(j)
            len_P = len(P)
            len_O = len(O)
            i = V[1]
            l[i] = "0"*(6-len_P) + P + "0"*(6-len_O) + O
            j += 1
            
    for num in l:
        print(num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 47632
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=100005;
struct _EDGE
{
    int to,nxt;
}e[MAXN<<2];
int n,m,egcnt,head[MAXN],ans[MAXN],d[MAXN];
bool ins[MAXN];
queue<int>q;

inline void addedge(int from,int to)
{
    e[++egcnt].to=to;
    e[egcnt].nxt=head[from];
    head[from]=egcnt;
    e[++egcnt].to=from;
    e[egcnt].nxt=head[to];
    head[to]=egcnt;
}

void spfa(int rt)
{
    memset(d, 0x3f, sizeof(d));
    d[rt] = 0;
    ins[rt] = true;
    q.push(rt);
    while(!q.empty())
    {
        int now = q.front();
        q.pop();
        ins[now]=false;
        for (register int i = head[now]; i; i = e[i].nxt)
        {
            if(d[e[i].to] > d[now] + 1)
            {
                d[e[i].to] = d[now] + 1;
                ans[e[i].to]=now;
                if(!ins[e[i].to])
                {
                    q.push(e[i].to);
                    ins[e[i].to] = true;
                }
            }
        }
    }

}

int main()
{
    read(n); read(m);
    for (int i=1,a,b;i<=m;++i)
    {
        read(a);
        read(b);
        addedge(a,b);
    }
    spfa(1);
    for (int i=2;i<=n;++i)
        if(d[i]>n)
        {
            printf("No");
            return 0;
        }
    printf("Yes\n");
    for (int i=2;i<=n;++i)
        printf("%d\n",ans[i]);
    return 0;
}

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

int main(int argc,char* argv[]){
  int input,num,tmp;num=1;cin >> input;
  while(num<=input){
    if(num%3==0){cout<<" "<<num;num++;}
    if(num>input) break;tmp=num;
    while(tmp!=0){if(tmp%10==3){ cout<<" "<<num;break;}tmp/=10;}
    num++;}
  cout<<endl;}

Measured memory_bytes: 3012
N = int(input())
A = list(map(int,input().split()))
 
P=[0]*(N+1)
P[N]=A[N]
Q=[0]*(N+1)
Q[N]=A[N]
 
for i in range(N,0,-1):
    mxp=P[i]+A[i-1]
    mnp=(P[i]//2) + (P[i]%2) +A[i-1]
    mxq=Q[i]+A[i-1]
    mnq=(Q[i]//2) + (Q[i]%2) +A[i-1]
    P[i-1]=mnp
    Q[i-1]=min(mxq,2**i)
 
if P[0]!=1:
    print(-1)
    exit()
 
Q[0]=1
 
for i in range(1,N):
    if Q[i]>2**i:
        Q[i]=2**i
    if Q[i]>(Q[i-1]-A[i-1])*2:
        Q[i]=(Q[i-1]-A[i-1])*2
 
print(sum(Q))

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N),b(N);
  int num=1,count=0;
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  while(num!=2){
    b.at(num-1)++;
    if(b.at(num-1)>1){
      break;
    }
    num=a.at(num-1);
    count++;
    if(num==2){
      break;
    }
  }
  if(num==2){
    cout << count << endl;
  }
  else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 1024
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);

	      	  int N;
	      	  cin >> N;

	      	  int ans=0;
	      	  REP(i,N){
	      		  int l,r;
	      		  cin >> l >> r;
	      		  ans+=r-l+1;
	      	  }

	      	  cout << ans << endl;


	          return 0;
}


Measured memory_bytes: 256
N = int(input())
zero = ["0"]
LST = input().split(" ")
LST = zero + LST + zero

s = 0
for i in range(len(LST)):
    if i < len(LST)-1:
        s += abs(int(LST[i]) - int(LST[i+1]))
    else:
        s += abs(int(LST[i]))
    

for i in range(len(LST)):
    if i > 0 and i < len(LST)-1:

        minus = 0
        temp = int(LST[i])
        prev = int(LST[i-1])
        past = int(LST[i+1])
        
        if (prev <= temp and temp <= past) or (past <= temp and temp <= prev):
            minus = 0
        elif past < temp:
            minus = abs(temp - past) + abs(temp - prev) - abs(prev - past)
        elif prev > temp:
            minus = abs(temp - past) + abs(temp - prev)- abs(prev - past)

        print(s - minus)

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

const int Max_n = 103;
int F[Max_n][10];
int P[Max_n][10];
//int c[Max_n];

int main(){
    int N;
    long long ans = -1000000000000;
    cin >> N;

    for(int i =0; i < N; i++){
        for(int j=0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i =0; i < N; i++){
        for(int j=0; j <= 10; j++){
            cin >> P[i][j];
        }
    }
    int t;

    for(int i =1; i < 1024; i++){
        int state = i;
        int c[N];
        for(int n=0; n < N; n++) c[n]=0;
        
        long long temp_ans = 0;
        for(int j=0; j < 10; j++){
            if((state %2) == 1){
                for(int n =0; n < N; n++){
                    c[n] += F[n][j];
                }
            }
            state /= 2;
        }
        for(int n=0; n < N; n++){
            temp_ans += P[n][c[n]];
        }
        ans = max(ans, temp_ans);
    }


    cout << ans << endl;
  
   

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int saidai(int a, int b){
  if( a > b)return a;
  return b;
}

int main(int argc, char const *argv[]) {
  int x=0;
  int n,i,max,tmp;
  char s[101];

  scanf("%d",&n );
  scanf("%s",s );
  max = x;
  for(i=0;i<n;i++){
    if(s[i] == 'I'){
      x++;
    }else{
      x--;
    }
    max = saidai(max , x);
    
  }

  printf("%d\n", max);
  return 0;
}

Measured memory_bytes: 128
N = gets.to_i
arr = gets.split.map(&:to_f)
nn = (N + 1) / 2
# dp = Array.new(N + 1){Array.new(nn + 1, 0)}
dp = Array.new(nn + 1, 0)
dp[0] = 1
N.times do |i|
  (nn - 1).downto(0) do |j|
    dp[j+1] += (dp[j] - dp[j+1]) * arr[i]
  end
end
# p dp
puts dp[nn]

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

int main () {
  int N, count;
  cin >> N;
  count = 0;
  
  for ( int i = 0 ; i < N ; i++ ) {
    int A, countA;
    cin >> A;
    countA = 0;
  
    for (;;){
      if (A % 2 == 1){
        if ( i == 0){
          count = countA;
        }
        
        if (count > countA){
          count = countA;
        }
        break;
      }
      A = A / 2;
      countA++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int main (void)
{
    int k;
    char s[102];

    scanf("%d", &k);
    scanf("%s", s);

    if (strlen(s) <= k) {
        puts(s);
    } else {
        s[k] = '\0';
        printf("%s...", s);
    }

    return 0;
}


Measured memory_bytes: 1684
#include<iostream>
using namespace std;
int main(void){
  string s;
  cin>>s;
  if(s[0] == 'C'){
    cout<<"Rainy"<<endl;
  }else if(s[0] == 'S'){
    cout<<"Cloudy"<<endl;
  }else{
    cout<<"Sunny"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

int main(){
	int H = 0, W = 0;
	cin >> H >> W;
	
	int box[51][51] = {};

	int count = 0;
	while(count < W){
		string line;
		cin >> line;
		for(int i = 0; i < line.length(); ++i){
			box[i][count] = line[i] == '#' ? 1 : 0;
		}

		count++;
	}


	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){

			if(box[i][j] == 1){
				if(j >= 1 && box[i][j-1] >= 1){ // left
					//cout << " : " << i << " " << j-1 << "left" << endl;
					box[i][j] = 2;
				} else if(i < W - 1 && box[i + 1][j] >= 1){ // bottom
					//cout << " : " << i+1 << " " << j << "bottom" << endl;
					box[i][j] = 2;
				} else if(j < H - 1 && box[i][j + 1] >= 1){ // right
					//cout << " : " << i << " " << j+1 << "right" << endl;
					box[i][j] = 2;
				} else if(i >= 1 && box[i - 1][j] >= 1){ // up
					//cout << " : " << i-1 << " " << j << "up" << endl;
					box[i][j] = 2;
				}
			}
		}
	}

	string ans = "Yes";
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(box[i][j] == 1) ans = "No";
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  string s;
  cin >> s;

  vector<int> cnt(3, 0);
  for (char c : s) {
    cnt[c - 'a']++;
  }

  cout << (max(cnt[0], max(cnt[1], cnt[2])) -
                       min(cnt[0], min(cnt[1], cnt[2])) <=
                   1
               ? "YES"
               : "NO")
       << endl;
  return 0;
}

Measured memory_bytes: 3680
import sys
from collections import deque
input = sys.stdin.readline
N = int(input())
bi=[0]* N
children = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    b-=1
    bi[i]=b
    children[a-1].append(b)

queue = deque([0])
colors = [0] * N
#maxColor = 0
while queue:
    node = queue.popleft()
    nodeColor = colors[node]
    color = 1
    for child in children[node]:
        if color == nodeColor: color += 1
        colors[child] = color
        queue.append(child)
        color += 1
    #maxColor = max(maxColor, color-1)

print(max(colors))
for i in range(N-1):
    print(colors[bi[i]])

Measured memory_bytes: 18560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back


long long int a,b;

void solve(){
	cin>>a>>b;
	cout<<a*b;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    solve();

	return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,l[100010],r[100010];
    pll a[100010];
    cin>>n;
    rep(i,n){
        cin>>l[i]>>r[i];
        a[i]={l[i],r[i]};
    }
    sort(a,a+n);
    ll b[100010],c[100010];
    pll B[100010],C[100010];
    pll now={a[0].fi,a[0].sc};
    rep(i,n){
        now.fi=max(now.fi,a[i].fi);
        now.sc=min(now.sc,a[i].sc);
        b[i]=max(0ll,now.sc-now.fi+1);
        B[i]=pll(now.fi,now.sc);
    }
    now={a[n-1].fi,a[n-1].sc};
    repr(i,n){
        now.fi=max(now.fi,a[i].fi);
        now.sc=min(now.sc,a[i].sc);
        c[i]=max(0ll,now.sc-now.fi+1);
        C[i]=pll(now.fi,now.sc);
    }
    ll ans=0;
    rep(i,n){
        ans=max(ans,b[i]+c[i+1]);
        // cout<<ans<<endl;
    }
    rep(i,n){
        ll s=a[i].sc-a[i].fi+1;
        pll t;
        if(i!=0){
            t.fi=B[i-1].fi,t.sc=B[i-1].sc;
        }
        if(i!=n-1){
            t.fi=max(t.fi,C[i+1].fi);
            t.sc=min(t.sc,C[i+1].sc);
        }
        s+=max(0ll,t.sc-t.fi+1);
        ans=max(ans,s);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    cout<<a[0]+a[1]+a[2]*10<<endl;

}



Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main (){
  int n;
  cin >> n;
  for(int i = 2 ; i <= 55555 && n; i++){
    int cnt =0 ;
    for(int j = 1 ; j * j <= i ; j++){
      if (i % j == 0)
        cnt += 1 + (i/j != j);
    }
    if (cnt == 2 && i % 10 == 1)
      cout << i <<' ', n--;
  }
  return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    N = int(input())
    L_list = list(map(int, (input().split(' '))))
    L_list.sort(reverse=True)
    L_max = L_list.pop(0)
    L_sum = sum(L_list)
    if L_sum > L_max:
        print('Yes')
    else:
        print('No')



Measured memory_bytes: 2940
n = int(input())
A = [int(i) for i in input().split()]

def countingSort(A, k):
    B = [0 for i in range(len(A))]
    C = [0 for i in range(k+1)]
    for a in A:
        C[a] += 1
    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]
    for a in reversed(A):
        B[C[a]-1] = a
        C[a] -= 1
    return B

print(*countingSort(A, 10000))



Measured memory_bytes: 224240
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int set;
            string[] input = Console.ReadLine().Split(' ');
            int min = 1000000;
            int max = -1000000;
            long sum = 0;

            for (int i = 0; i < n; i++)
            {
                set = int.Parse(input[i]);
                if (min > set)
                {
                    min = set;
                }
                if (max < set)
                {
                    max = set;
                }
                sum += set;
            }
            Console.WriteLine(min+" "+max+" "+sum.ToString("0"));
            
        }
    }
}

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

using namespace std;

int main(){

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

  int p[n];
  for(int i=0; i<n; i++) cin>>p[i];
  
  sort(p,p+n);

  int sum=0;
  for(int i=0; i<k; i++){
    sum += p[i];
  }

  cout<<sum<<endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

char c[301][301];
char field[301][2];

int H, W;
int memo[301][301];
int cost[301][301];

int cost_dfs(int h_0, int h_1){
    if(h_0 == 0 || h_1 == 0) return 0;
    if(cost[h_0][h_1] != -1) return cost[h_0][h_1];
    cost[h_0][h_1] = cost_dfs(h_0 - 1, h_1 - 1);

    int offset_0 = 0, offset_1 = 0;
    if(h_0 > h_1) offset_0 = h_0 - h_1;
    if(h_1 > h_0) offset_1 = h_1 - h_0;
    int i = min(h_0, h_1) - 1;
    if(field[offset_0 + i][0] == field[offset_1 + i][1]){
        cost[h_0][h_1]++;
    }

    return cost[h_0][h_1];
}

int dfs(int h_0, int h_1){
    if(h_0 == 0 || h_1 == 0) return 0;
    if(memo[h_0][h_1] != -1) return memo[h_0][h_1];

    int ret = cost_dfs(h_0, h_1);
    ret += min(dfs(h_0 - 1, h_1), dfs(h_0, h_1 - 1));
    memo[h_0][h_1] = ret;
    return ret;
}
 
int main(){
    cin >> H >> W;

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin >> c[i][j];
        }
    }

    ll ans = 0;
    for(int x=0;x<W-1;x++){
        for(int i=0;i<H;i++){
            field[i][0] = c[i][x];
            field[i][1] = c[i][x + 1];
        }
        memset(memo, -1, sizeof(memo));
        memset(cost, -1, sizeof(cost));
        ans += dfs(H, H);
    }

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

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;
const int maxn = 1e5+10;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int r,s,p;
char c[maxn];
bool check[maxn];
int main(){	
	n=read();k=read();
	r=read();s=read();p=read();
	scanf("%s",c+1);
	long long ans=0;
	for(register int i=1;i<=n;i++){
		if(i>=k && c[i]==c[i-k] && check[i-k])continue;
		check[i]=1;
		if(c[i]=='r')ans+=p;
		if(c[i]=='p')ans+=s;
		if(c[i]=='s')ans+=r;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 384
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2198

#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
  int N;
  while(scanf("%d", &N) != EOF && N) {
    vector<pair<double,string>> V;
    string L;
    int P, A, B, C, D, E, F, S, M;
    for (int t=0; t<N; t++) {
      cin >> L;
      scanf("%d%d%d%d%d%d%d%d%d", &P, &A, &B, &C, &D, &E, &F, &S, &M);
      int rew = F * M * S - P;
      int time = A + B + C + (D + E) * M;
      double rat = ((double)rew) / time;
      V.push_back(make_pair(-1 * rat, L));
    }
    sort(V.begin(), V.end());
    for (unsigned int i=0; i<V.size(); i++) {
      cout << V[i].second << endl;
    }
    cout << "#" << endl;
  }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> ii;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
const ld pi = 4.0 * atanl(1.0);
const int iinf = 1e9 + 10;
const int inf = 1e18 + iinf + 10;
const int mod = 1000000007;
const ld prec = .000001;

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()

int n, m, t, a[mxN];
vi v;

void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }

int main() {
  fast();
  string s;
  cin >> s;
  int ans = 0, mx = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T')
      ans = 0;
    else
      ++ans;
    mx = max(ans, mx);
  }
  cout << mx;

  return 0;
}



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

int main(){
    string s;
    cin>>s;
    int num=0;
    rep(i,s.size()) if(s[i]=='o') num++;
    cout<<700+100*num<<"\n";
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  ll ans=1e10;
  rep(i,n){
    ll b=a[i];
    ll cnt=0;
    while(b%2==0){
      cnt++;
      b/=2;
    }
    if(cnt<ans) ans=cnt;
  }
  cout<<ans<<endl;
}

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

int primecheck(int m){
    int i;
    
    if(m==1)return 0;
    if(m==2||m==3)return 1;
    for(i=2;i<=sqrt(m);i++){
        if(m%i==0)return 0;
    }
    return 1;
}

int main(void){
    int i,n;
    
    while(scanf("%d",&n) != EOF){
        for(i=n-1;;i--){
            if(primecheck(i)){
                printf("%d ",i);
                break;
            }
        }
        
        for(i=n+1;;i++){
            if(primecheck(i)){
                printf("%d\n",i);
                break;
            }
        }
    }
    
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    if((N / 1000 == N / 100 % 10 && N / 100 % 10 == N / 10 % 10) || (N / 100 % 10 == N / 10 % 10 && N / 10 % 10 == N % 10)){
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,a[100002],u=0;
int main() {cin>>n;
	for (int i=1,l,r;i<=n;i++) {
		cin>>l>>r;
		a[l]++;a[r+1]--;
	}
	for (int i=1;i<=100000;i++)
		if (a[i]+=a[i-1]) u++;
	cout<<u<<endl;
	return 0; 
}

Measured memory_bytes: 640
#include <iostream>

#ifdef LOCAL
  #define debugEcho(expr) cout << expr << "\n";
#else
  #define debugEcho(expr)
#endif

using namespace std;

#define at ,<=,
#define to ,<,
#define in ,
#define forrange(...)  forrange1(forrange2, (__VA_ARGS__))
#define forrange1(X, A) X A
#define forrange2(i, s, op, e) for (int i = (s); i op (e); i++)

int main() {
  string S;
  cin >> S;

  bool asciimap[26] = {0};
  bool t = true;
  for (auto c : S) {
    char cm = c-97;
    if (asciimap[cm]) {
      t = false;
      break;
    }
    asciimap[cm] = true;
  }
  if (t) {
    cout << "yes\n";
  } else {
    cout << "no\n";
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(void){
    cout<<fixed<<setprecision(6);
    
    int n;
    double x[1001]={}, y[1001]={};
    double d1=0.0, d2=0.0, d3=0.0, di=0.0;
    
    cin>>n;
    for(int i=0; i<n; i++) cin>>x[i];
    for(int i=0; i<n; i++) cin>>y[i];
    
    for(int i=0; i<n; i++){
        d1+=fabs(x[i]-y[i]);
        d2+=fabs(x[i]-y[i])*fabs(x[i]-y[i]);
        d3+=fabs(x[i]-y[i])*fabs(x[i]-y[i])*fabs(x[i]-y[i]);
        di=max(di, fabs(x[i]-y[i]));
    }
    
    cout<<d1<<endl;
    cout<<sqrt(d2)<<endl;
    cout<<pow(d3, 1.0/3.0)<<endl;
    cout<<di<<endl;;
    
    return 0;
}



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

//素数判定
template<class T>
bool isPrime(T n){
    if(n < 2) return false;
    for(T i = 2; i*i < n; ++i) if(n % i == 0) return false;
    return true;
}

int main(){
    int x; cin >> x;
    int ans = 2;
    while(1){
        if(ans >= x && isPrime(ans)){
            cout << ans << endl;
            return 0;
        }
        ans++;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;

ll powmod(ll x, ll y) {
	ll res = 1;

	for (ll i = 0; i < y; i++) {
		res = res * x % mod;
	}

	return res;
}

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

	ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);


	ans %= mod;
	ans = (ans + mod) % mod;

	cout << ans << "\n";
}


Measured memory_bytes: 3612
import numpy as np

N, weights = map(int, input().split())

# dp = [0] * (weights + 1)
dp = np.zeros(weights + 1, dtype=np.int64)

while N:
    w, v = map(int, input().split())
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])
    # for i in range(weights, -1, -1):
    #     if i - w >= 0:
    #         dp[i] = max(dp[i], dp[i - w] + v)
    # print(dp)
    N -= 1
print(dp[-1])

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

int main() {
    int n,k;
    string s;
    string asterisk = "*";
    cin >> n;
    cin >> s;
    cin >> k;
    string target = s.substr(k-1,1);

    for(int i=0;i<n;i++){
       if(s.substr(i, 1) != target){
           s.replace(i,1, asterisk);
       }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx - sx, ty - sy
ans = ""
ans += 'R' * dx + 'U' * dy
ans += 'L' * dx + 'D' * dy
ans += 'D'
ans += 'R' * (dx + 1) + 'U' * (dy + 1)
ans += 'LU'
ans += 'L' * (dx + 1) + 'D' * (dy + 1)
ans += 'R'
print(ans)


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld=long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, rev;
    long double cap;
	Edge(ll _to, long double _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, long double cap, bool revFlag, long double revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}



void solve(){
    long double a,b;
    cin>>a>>b;
    cout<<(ll)(a*b)<<en;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
	//ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b;
    cin >> a >> b;

    int c = 0;
    bool check;
    for(int i=a; i <= b; i++){
        string str = to_string(i);
        int len = str.length() - 1;
        check = false;
        int k = len;
        rep(j, len){
           if(str[j] != str[k--]){
               break;
           }
           if(len%2==0){
               if(j == k+1){
                 check = true;
               }
           }
           else{
               if(len/2 == j){
                   check = true;
               }
           }
        }
        if(check){
            c++;
        }
    }
    std::cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long maxn=2000+2,mod=1000000000+7;
long long ans=0,n,k,cou=0;
int a[maxn];
int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(a[i]>a[j]) ++ans;
	ans=ans*k%mod;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(a[i]>a[j]) ++cou;
	ans+=cou*((k-1)*k/2%mod)%mod;
	ans%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256