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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int X = sc.nextInt();
    int[] C = new int[N];
    int[][] A = new int[N][M];
    for (int i = 0; i < N; i++) {
      C[i] = sc.nextInt();
      for (int j = 0; j < M; j++) {
        A[i][j] = sc.nextInt();
      }
    }
    sc.close();

    long ans = -1;
    long max = 1 << 12;
    for (long n = 1; n < max; n++ ) {
      long sumC = 0;
      long[] sumA = new long[M];
      for (int i = 0; i < N; i++)
        if ((n >>> i) % 2 == 1) {
          sumC += C[i];
          for (int j = 0; j < M; j++)
            sumA[j] += A[i][j];
        }

      boolean ok = true;
      for (int j = 0; j < M; j++)
        if (sumA[j] < X) ok = false;

      if (ok && (ans < 0 || sumC < ans))
        ans = sumC;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 37796
#include<iostream>
#include<queue>

using namespace std;

int main(){
  priority_queue<int> que;
  int aque[3];

  int A,B,C,ans;
  cin>>A>>B>>C;
  que.push(A);
  que.push(B);
  que.push(C);
  
  for(int i=0;i<3;i++){
    aque[i]=que.top();
    que.pop();
  }

  int sum=aque[0]%2+aque[1]%2+aque[2]%2;

  if(sum==0 || sum==3){
    ans=(aque[0]-aque[1])/2+(aque[0]-aque[2])/2;
  }
  else if(sum==1){
    for(int i=0;i<3;i++){
      if(aque[i]%2==0)aque[i]+=1;
      ans=(aque[0]-aque[1])/2+(aque[0]-aque[2])/2+1;
    }
  }
  else{
    for(int i=0;i<3;i++){
      if(aque[i]%2==1)aque[i]+=1;
      ans=(aque[0]-aque[1])/2+(aque[0]-aque[2])/2+1;
    }
  }

  cout<<ans<<endl;

  return 0;
}




Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
int a, b;
	
	
	scanf("%d""%d",&a,&b);
	
	if(a>b){
		printf("a > b\n");
	}
		else if(a<b){
			printf("a < b\n");
		}
			else{
				printf("a == b\n");
	}

return 0;
}

Measured memory_bytes: 580
n = int(input())
p = [0 for i in range(n+1)]
m = [[0 for i in range(100)] for j in range(100)]

for i in range(n):
    p[i], p[i+1] = map(int, input().split())
     
for l in range(2, n+1):
    for i in range(1, n-l+2):
        j = i+l-1
        m[i][j] = float("inf")
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j])
 
print(m[1][n])

Measured memory_bytes: 7880
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std;
int main(){
  string A,B;
  cin>>A>>B;
  if(A.size()>B.size()) printf("GREATER\n");
  else if(A.size()<B.size()) printf("LESS\n");
  else if(A>B) printf("GREATER\n");
  else if(A<B) printf("LESS\n");
  else printf("EQUAL\n");
  return 0;
}


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

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

int main(){
	int n, d;
    cin >> n >> d;
    int a =  (d*2) + 1;
    cout << (n + a - 1) / a;
    
    return 0;
}


Measured memory_bytes: 256
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

N,A = ilint()
C = counter()
for a in A:
    C.add(a)
ans = 0
for k in C:
    ans += C[k] if C[k]<k else C[k]-k
print(ans)

Measured memory_bytes: 102372
#include<stdio.h>
#include<stdbool.h>

int main(void){

	int n;
	int a[100001];
	int ans = 0;
	int b = 1;
	bool f = false;

	scanf("%d", &n);

	for(int i= 0; i < n; i++){
		scanf("%d", &a[i]);
	}

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

		b = a[b-1];
		ans++;

		if(b==2){
			f = true;
			break;
		}


		


	}

	if(f == false){
		ans = -1;
	}

	printf("%d", ans);

	return 0;
}

Measured memory_bytes: 512
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int r[50][202020];
int n, l, q;
int x[202020];

int main() {
	cin >> n;
	REP(i, n)cin >> x[i];
	x[n] = x[n - 1] + 1;
	cin >> l;
	REP(i, n+1) {
		r[0][i] = upper_bound(x, x + n+1, x[i]+ l) - x - 1;
	}
	for (int i = 1; i < 17;i++)REP(j, n + 1) {
		r[i][j] = r[i-1][r[i-1][j]];
	}
	cin >> q;
	int a, b;
	REP(Q, q) {
		cin >> a >> b;
		a--, b--;
		if (a > b) {
			swap(a, b);
		}
		int cur = a, ans = 0;
		for (int i = 16; i >= 0; i--) {
			if (r[i][cur] <= b) {
				cur = r[i][cur];
				ans += (1 << i);
			}
		}
		if (cur < b)ans++;
		cout << ans << endl;
	}
}

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

int X,Y,Z,N,M;
int x[110],y[110];
int main(){
	cin >> N >> M >> X >> Y;
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	for(int i=0;i<M;i++){
		cin >> y[i];
	}
	sort(x,x+N);
	sort(y,y+M);
	bool judge = false;
	for(int i=X+1;i<Y;i++){
		if(x[N-1]<i && y[0]>=i) judge = true;
	}
	cout << (judge? "No War":"War") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;

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

  return 0;
}


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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}

int n,k;
// dp[i] -> true if 1st player wins if there are i stones remaining

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    vi a(n);
    cin >> a;
    vector<bool> dp(k + 1);
    for(int stones = 0; stones <= k; ++stones){
        for(int x : a){
            if(stones >= x && !dp[stones - x]){
                dp[stones] = true;
            }
        }
    }
    cout << (dp[k]?"First":"Second");
}

Measured memory_bytes: 256
import math
import cmath
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

atan = math.atan2
deg = math.degrees
eps = 1e-9

N = int(input())
arg = []
XY = []
for i in range(N):
    x, y = map(int, input().split())
    arg.append((deg(atan(y, x)), x, y))
arg.sort()
arg += [(th + 360, x, y) for th, x, y in arg]

dth = 360 / (5000)
th = 0
ans = 0
for _ in range(5001):
    X = 0
    Y = 0
    for a, x, y in arg:
        if abs(th - a) < 90 + eps:
            X += x
            Y += y
    ans = max(ans, X ** 2 + Y ** 2)
    th += dth

print("{:.40f}".format(ans**0.5))

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define int long long
using namespace std;

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

int lcm(int a,int b){
    //cout<<"# "<<gcd(a,b)<<endl;
    return  (a*b)/gcd(a,b);
}

int32_t main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int ans = (b-a+1) - ((b/c-(a-1)/c)+(b/d-(a-1)/d));

    int lc = lcm(c,d);
    //cout<<lc<<endl;

    ans += (b/lc - (a-1)/lc);

    cout<<ans<<endl;
}


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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void print(T a) { cout<<a<<"\n"; }
template <typename T>
inline void print(T a, T b) { cout<<a<<" "<<b<<"\n"; }
template <typename T>
inline void print(T a, T b, T c) { cout<<a<<" "<<b<<" "<<c<<"\n"; }
template <typename T>
inline void print(T a, T b, T c, T d) { cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"; }
template <typename T>
inline void printpii(pair<T, T> p) { cout<<p.first<<" "<<p.second<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}

template <typename T>
inline void readV(vector<T>& a) { rep(i, 0, sz(a)) cin>>a[i]; }
template <typename T>
inline void read(T& a) { cin>>a; }
template <typename T>
inline void read(T& a, T& b) { cin>>a>>b; }
template <typename T>
inline void read(T& a, T& b, T& c) { cin>>a>>b>>c; }
template <typename T>
inline void read(T& a, T& b, T& c, T& d) { cin>>a>>b>>c>>d; }
template <typename T>
inline void readpii(pair<T, T>& p) { cin>>p.first>>p.second; }
template <typename T>
inline void readVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		readV(a[i]);
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n, W;
	cin>>n>>W;
	vector<ll> w(n+1);
	vector<ll> val(n+1);
	vector<vector<ll>> dp(W+1, vector<ll>(n+1));
	for(int i=1; i<=n; i++) {
		cin>>w[i]>>val[i];
	}
	
	for(int i=1; i<=W; i++) {
		for(int j=1; j<=n; j++) {
			if(i>=w[j]) {
				dp[i][j]=max(dp[i][j-1], dp[i-w[j]][j-1]+val[j]);
			}
			else {
				dp[i][j]=max(dp[i][j], dp[i][j-1]);
			}
		}
	}
	//~ printVV(dp);
	
	
	cout<<dp[W][n]<<"\n";
    return 0;
}



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

using namespace std;

int const MAX_E = 100;
int const INF = INT_MAX;

int edge[MAX_E][MAX_E];

int main() {
  
  int V, E;  cin >> V >> E;
  
  fill(edge[0], edge[MAX_E], INF);
  
  for(int i=0; i<V; i++) edge[i][i] = 0;
  
  for(int i=0; i<E; i++) {
    int s, t, d; cin >> s >> t >> d;
    edge[s][t] = d;
  }
  
  for(int k=0; k<V; k++) {
    for(int i=0; i<V; i++) {
      for(int j=0; j<V; j++) {
	if(edge[i][k] != INF && edge[k][j] != INF) {
	  edge[i][j] = min(edge[i][j], edge[i][k] + edge[k][j]);
	}
      }
    }
  }
  
  for(int i=0; i<V; i++) {
    if(edge[i][i] < 0) {
      cout << "NEGATIVE CYCLE" << endl;
      exit(0);
    }
  }
  
  for(int i=0; i<V; i++) {
    for(int j=0; j<V; j++) {
      if(j) cout << " ";
      if(edge[i][j] == INF) cout << "INF";
      else cout << edge[i][j];
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14


int main(){
	ll a, b; cin >> a >> b;
	cout << a*b << endl;
} 

Measured memory_bytes: 3632
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, m] <- getIntList

  let nScc1 = min (2 * n) m `div` 2
      m' = m - nScc1 * 2
      nScc2 = m' `div` 4
      ans = nScc1 + nScc2

  print ans

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

using namespace std;
int main(){
	long long w,a,b, minDes;
	cin>>w>>a>>b;
	if(b>(a+w)){
		minDes = b-(a+w);
	}else if(b<(a+w) && b>a){
		minDes = 0;
	}else if(b<a && (b+w)<a){
		minDes = a-(b+w);
	}
	cout<<minDes;
	return 0;

}

Measured memory_bytes: 256
a, b = map(int, input().split())
if b > 0:
    if (a + b) > (a * b):
        print(a + b)
    else:
        print(a * b)
elif b == 0:
    print(a)
else:
    if (a - b) > (a * b):
        print(a - b)
    else:
        print(a * b)



Measured memory_bytes: 3060
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, M = map(int, readline().split())
se = set(range(M + 1))
for _ in range(N):
    enquete = [int(x) for x in readline().split()]
    se &= set(enquete[1:])

print(len(se))


Measured memory_bytes: 12444
'''


'''
# from collections import deque # キュー、スタックに利用
# import math # 数学的計算に利用
# import numpy as np # 行列計算などに利用

# sys.stdin.readline() # 標準入力の高速化に利用
import sys
input = sys.stdin.readline

def main():
    '''メイン処理'''
    all_sum = 0
    # 最後の改行を除いて受け取り
    S = input().strip()
    # +を入れる位置は、len(S)-1の数だけある。まずは空文字を入れておく
    n = (len(S)-1)    
    # +を入れるパターンは、2**n通り
    for i in range(2**n):
        ope_list = [""] * n
        # n桁の2進数文字列を生成
        bin_str = bin(i)[2:].zfill(n)
        # 2進数で1の立っている桁をフラグとみなし、opを1へ書き換え
        for j in range(n):
            if bin_str[j] == '1':
                ope_list[j] = "+"
        
        calc_str = S[0]
        for s, ope in zip(S[1:], ope_list):
            calc_str += ope+s
        all_sum += eval(calc_str)
    
    print(all_sum)


if __name__ == "__main__":
    # ファイル実行時に、main()関数を実行
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

#define ll long long
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+500;

vector<ll> out[maxn];
vector<ll> in[maxn];
vector<ll> topol;
bool vis[maxn];
ll par[maxn];

void dfs(ll a){
	vis[a]=1;
	for(auto e:out[a]){
		if(!vis[e])dfs(e);
	}
	topol.pb(a);
}
ll koj[maxn];
void dfs_ans(ll a){
	vector<pii> vec;
	for(auto r:out[a]){
		vec.pb(mp(koj[r],r));
	}
	sort(vec.begin(),vec.end());
	vis[a]=1;
	for(auto e:vec){
		if(vis[e.S]==0){
			dfs_ans(e.S);
			par[e.S]=a;
		}
	}
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n,m,rot;
	cin>>n>>m;
	for(ll i=0;i<m+n-1;i++){
		ll a,b;
		cin>>a>>b;
		out[a].pb(b);
		in[b].pb(a);
	}
	for(ll i=1;i<=n;i++){
		if(in[i].empty()){
			rot=i;
		}
	}
	dfs(rot);
	memset(vis,0,sizeof vis);
	reverse(topol.begin(),topol.end());
	for(ll i=0;i<n;i++){
		koj[topol[i]]=i;
	}			
	dfs_ans(rot);
	for(ll i=1;i<=n;i++){
		cout<<par[i]<<endl;
	}
}




















Measured memory_bytes: 26744
# coding: utf-8
# Your code here!
while True:
    n,k=map(int,input().split())
    if n+k==0:
        break
    a=[int(input()) for i in range(n)]
    s=sum(a[0:k])
    ss=[s]
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        ss.append(s)
    print(max(ss))


Measured memory_bytes: 11708
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
	ll n, k;
	cin >> n >> k;
	ll ans = 1;
	for (int i = 1; i <= n; i++) {
		if (i == 1) ans *= k;
		else ans *= k - 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <string>
int main() {
  std::string str1="", str2="";
  char ch;
  while ((ch = getchar()) != '\n') {
    str1 += ch;
  }
  while ((ch = getchar()) != '\n') {
    str2 += ch;
  }
  str1 = str1 + str1;
  if (str1.find(str2) != std::string::npos) printf("Yes\n");
  else                 printf("No\n");
  return 0;
}



Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const ll mod = 1e9+7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        string s; cin >> s;
        ll f=0;
        rep(i,sz(s)-1){
            if(s[i]=='A' and s[i+1]=='B'){
                f=1; break;
            }
            if(s[i]=='B' and s[i+1]=='A'){
                f=1; break;
            }
        }
        if(f){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

double pi=acos(-1);
double a,b,h,m;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>a>>b>>h>>m;

    double hh=30*h+0.5*m;
    double mm=6*m;
    double ang=hh-mm;
    if(ang>180) ang=360-ang;
    ang=(pi/180)*ang;
    double res=sqrt(a*a+b*b-2*a*b*cos(ang));
    printf("%.20lf\n",res);

    return 0;
}

Measured memory_bytes: 4148
////////////////////////////////////////////////////
                    //                                                //
                    //  For her who keeps the fire kindling in me...  //
                    //                                                //
                    ////////////////////////////////////////////////////

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
// import java.util.Scanner;
// import java.util.Arrays;
// import java.util.ArrayList;
// import java.util.Collections; 
// import java.util.StringTokenizer;
import java.util.*;
import java.lang.Math;
import java.awt.Point;

import java.awt.geom.*;

public class Main {

    public static void main(String args[]) {
        try {
            FastReader s = new FastReader();
            BufferedWriter w = new BufferedWriter(new OutputStreamWriter(System.out));
            int m, n, t, i, j, max, x, y, min, ans;
            long a, b;


            String str = s.next();
            char c = str.charAt(0);

        
            c++;
            w.write(c+ "\n");
            w.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

// ========================================### FAST IO ###=========================================//
class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    Double nextDouble() {
        return Double.parseDouble(next());
    }

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}
// ====================================================================================================//

Measured memory_bytes: 21588
#include<cstdio>
#include<algorithm>
using namespace std;

int na,nb;
int a[5000],b[5000];
int dp[2][5001];

int main(){
  scanf("%d%d",&na,&nb);
  for(int i=0;i<na;i++)scanf("%d",&a[i]);
  for(int i=0;i<nb;i++)scanf("%d",&b[i]);
 
  for(int i=0;i<2;i++)
    for(int j=0;j<=nb;j++)dp[i][j] = 0;
  
  int ans = 0;
  for(int i=0;i<na;i++)
    for(int j=0;j<nb;j++){
      int t = (i&1)?1:0;
      dp[1-t][j+1] = max(dp[1-t][j+1],dp[t][j+1]);
      if(a[i] == b[j]){
	dp[1-t][j+1] = max(dp[1-t][j+1],dp[t][j]+1);
	ans = max(ans,dp[1-t][j+1]);
      }
    }
  printf("%d\n",ans);
}
  

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  for(int i=0;i<n;i++){
    int k;  cin >> k;
    for(int j=0;j<k;j++){
      int l;  cin >> l;
      a.at(l-1)++;
    }
  }
  
  int k=0;
  
  for(int i=0;i<m;i++){
    if(a.at(i)==n)
      k++;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

n = int(input())
as_ = list(map(int, input().strip().split()))


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


lcm_as = lcm_list(as_)

b_sum = sum([lcm_as // a for a in as_]) % 1000000007

print(b_sum)


Measured memory_bytes: 264644
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<ll,ll>
	#define PB push_back
	inline void chmax(ll &x,ll y) {x=x>y?x:y;}
	inline void chmin(ll &x,ll y) {x=x<y?x:y;}

	const int MOD=1e9+7;
	const int MAX_N=1e5+10;
	char s[MAX_N];
	int f[30];
	void main()
	{
		int n;scanf("%d",&n);
		scanf("%s",s+1);for(int i=1;i<=n;i++) f[s[i]-'a']++;
		ll ans=1;for(int i=0;i<26;i++) ans=ans*(f[i]+1)%MOD;
		printf("%lld",(ans+MOD-1)%MOD);
 	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 384
/*
	ID: sixathofpain
	TASK: friday
	LANG: C++   

*/


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

typedef pair<int, int> pii;

bool comp(pii &a,pii &b){
    return (a.ff+a.ss)<(b.ff+b.ss);
}
bool comp2(pii &a,pii &b){
    return (a.ff-a.ss)<(b.ff-b.ss);
}


int32_t main(){
    IOS;
	
    // freopen("friday.in","r",stdin);
    // freopen("friday.out","w",stdout);

    int n;
    cin>>n;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].ff>>v[i].ss;
    }
    sort(all(v),comp);
    int ans;
    ans = abs(v[0].ff+v[0].ss-(v[n-1].ff+v[n-1].ss));

    sort(all(v),comp2);
    ans = max(ans,abs(v[0].ff-v[0].ss-(v[n-1].ff-v[n-1].ss)));
    cout<<ans<<endl;


    return 0;
}

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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
/*
think fast
think simple
*/
void mysol()
{
	int n; cin >> n;
	string s;
	while (n > 0)
	{
		if (n % 26 == 0)
		{
			s += 'z';
			n /= 26;
			n--;
			continue;
		}
		s += (char)('a' - 1 + (n % 26 ) );
		n /= 26;
	}
	reverse(all(s));
	cout << s << endl;
}

int32_t main()
{
	//fast();
	//w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


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

int main(){
  bool prime[1000000] = {};
  int sum[1000000]; sum[0] = sum[1] = 0; sum[2] = 1;
  for(int i = 3 ; i < 1000000 ; i += 2 ){
    sum[i] = sum[i + 1] = sum[i - 1];
    if(!prime[i]){
      for(int j = i + i + i ; j < 1000000 ; j += i + i ){
        prime[j] = true;
      }
      sum[i]++;
      sum[i+1]++;
    }
  }

  int n;
  while(cin >> n){
    cout << sum[n] << endl;
  }
}

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

using namespace std ;

const int MAX = 2e5 + 10 ;

int arr[MAX] , freq[MAX] ;
int n , k ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>k ;
	for(int i = 0 ; i < n ; ++i)
	{
		cin>>arr[i] ;
		freq[arr[i]]++ ;
	}
	vector<int>v ;
	for(int i = 0 ; i < n ; ++i)
	{
		if(freq[arr[i]] > 0)
			v.push_back(freq[arr[i]]) ;
		freq[arr[i]] = 0 ;
	}
	sort(v.rbegin() , v.rend()) ;
	int ans = 0 ;
	for(int i = k ; i < v.size() ; ++i)
		ans += v[i] ;
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
int a[30][100005]={0},b[200005]={0};
int main()
{
    int n,c;
    scanf("%d%d",&n,&c);
    for(int i=0;i<n;i++)
    {
        int l,r,x;
        scanf("%d%d%d",&l,&r,&x);
        a[x-1][l]++;
        a[x-1][r]--;
    }
    int mm=0;
    for(int i=0;i<100005;i++)
    {
        if(i==0)
        {
            for(int j=0;j<c;j++)
            {
                b[i]+=a[j][i];
                if(a[j][i+1]>0)
                {
                    b[i]++;
                    a[j][i+1]=0;
                }
            }
        }
        else
        {
            b[i]=b[i-1];
            for(int j=0;j<c;j++)
            {
                b[i]+=a[j][i];
                if(a[j][i+1]>0)
                {
                    b[i]++;
                    a[j][i+1]=0;
                }
            }
        }
        mm=max(mm,b[i]);
        //if(i<=9)
        //cout<<b[i]<<endl;
    }
    cout<<mm<<endl;

}


Measured memory_bytes: 12416
#include <functional>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <climits>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <deque>
#include <list>
#include <map>
#include <set>
using namespace std;

/*** typedef ***/
typedef long long LL;
typedef unsigned int ui;
typedef unsigned long long ULL;
typedef pair < int , int > ii;
typedef pair < LL  , LL  > ll;
typedef vector <int>  vint;
typedef vector <bool> vbool;
typedef vector <long> vlong;

/*** define ***/
#define sz(x)			((int)x.size())
#define tin(x)			scanf("%d",&x)
#define all(x)			x.begin(),x.end()
#define Set(b,a)		memset(b,a,sizeof b)
#define print1(x)		printf("Case %d:",x++)
#define tin2(x,y)		scanf("%d%d",&x,&y)
#define tin3(x,y,z)		scanf("%d%d%d",&x,&y,&z)
#define loop(i,i0,in)	for(int i=i0 ; i<in ; i++)
#define rep(i,n)		for(int i=0 ; i<(n) ; i++)
#define _rep(i,n)		for(int i=n-1 ; i>=0 ; i--)
#define _loop(i,in,i0)	for(int i=in-1 ; i>=i0 ; i--)
#define Fore(it, x)		for(typeof (x.begin()) it = x.begin(); it != x.end (); it++)
     
int main()  
{  
#ifdef Online_Judge
	freopen("a.in","r",stdin);
#endif
	int seq[3];
	rep(i,3)cin>>seq[i];
	sort(seq,seq+3);
	cout << seq[0] << " " << seq[1] << " " << seq[2] << endl;
	return 0;
}

Measured memory_bytes: 1180
import math
x=int(input())
log_x=int(math.log(x,2))
cand=[0 for i in range(1001)]
cand[0]=1
for i in range(2,1000):
    cand[i]=int(pow(x,1.0/i))**i
cand[1000]=1000
print(max(cand[:x+1]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define re cin>>
#define pr cout<<
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)


const int N=2e6+5;
const int mod=1e9+7;


int main(){
      
      cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
      int n;
      string s;
      cin>>n>>s;
      
      int cr=0,cw=0;
      for(int i=0;i<s.size();i++){
            if(s[i]=='R') cr++;
            else cw++;
      }

      string ss;
      for(int i=0;i<cr;i++) ss.push_back('R');
      for(int i=0;i<cw;i++) ss.push_back('W');
      
      int chr=0,chw=0;
      for(int i=0;i<n;i++) {
            if(s[i]==ss[i]) continue;
            if(ss[i]=='R') chr++;
            else chw++;
      }
      
      cout<<max(chr,chw);
      return 0;
}

Measured memory_bytes: 3868
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,i,n=0,x;
	cin>>a>>b>>c;
	for(i=1;i<=a;i++)
	{
		cin>>x;
		if(x<b||x>=c) n++;
	}
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


vector<int> p(100),s(100);

void solve(int n, int w, int d){
    vector<pair<int,int> > items;
    items.reserve(100*100);
    items.push_back(make_pair(w,d));

    for(int i = 0; i < n; i++){
        auto it = items.begin()+(p[i]-1);
        pair<int,int> a,b;
        s[i] %= it->first+it->second;
        if((*it).first > s[i]){
            a.first = s[i];
            a.second = (*it).second;
            b.first = (*it).first-s[i];
            b.second = (*it).second;
        } else {
            a.first = it->first;
            a.second = s[i]-it->first;
            b.first = it->first;
            b.second = it->second-(s[i]-it->first);
        }
        if(a.first*a.second > b.first*b.second) swap(a,b);
        items.push_back(a);
        items.push_back(b);
        items.erase(it);
    }

    multiset<int> ans;
    for(int i = 0; i < items.size(); i++){
        ans.insert(items[i].first*items[i].second);
    }
    for(auto it = ans.begin(); it != ans.end(); it++){
        if(it != ans.begin()){
            cout << " ";
        }
        cout << (*it);
    }
    cout << endl;
}

int main(){
    while(true){
        int n,w,d;
        cin >> n >> w >> d;
        if(n == 0 && w == 0 && d == 0){
            break;
        }
        p.clear();
        s.clear();
        for(int i = 0; i < n; i++){
            cin >> p[i] >> s[i];
        }
        solve(n,w,d);
    }


    return 0;
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define loop(i, sta, end, inc) for(int i = sta; i <= end; i += inc)
#define itr(it, l)             for(auto it = l.begin(); it != l.end(); it ++)
#define in(a, b, c)            assert( b <= a && a <= c)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define what_is(x) cerr<<#x<<" ="<<x<<" ";
#define error(args...)  { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define LINT_MAX  9223372036854775807
#define LINT_MIN -9223372036854775808
#define EPS 1e-9
#define MOD 1000000007
#define DEBUG 0

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
void err(istream_iterator<string> it) { cerr<<endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    if(DEBUG == 0)return;
	cerr << *it << " = " << a <<" ";
	err(++it, args...);
}
int A[100000];
int dp[100000];
int main(){
    //freopen("test.txt", "r", stdin);
    int n,k;cin>>n>>k;
    forn(i,n)cin>>A[i];
    dp[0]=0;
    dp[1]=dp[0]+abs(A[1]-A[0]);
    for(int i=2; i < n ;i++){
      int temp=INT_MAX;
      for(int j=1;j<=k;j++){
      	if(i<j)break;
      	temp=min(temp,(dp[i-j]+abs(A[i]-A[i-j])));
      }
      dp[i]=temp;
    }
    cout<<dp[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
 
public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
 
    void solve() throws IOException {
    	int n = in.nextInt();
    	long sum = 0;
    	for(int i = 0; i < n; i++) {
    		int l = in.nextInt();
    		int r = in.nextInt();
    		sum += r - l + 1;
    	}
    	System.out.println(sum);
    }
 
}
 
@SuppressWarnings("serial")
class MultiSet<T> extends HashMap<T, Long>{
    @Override public Long get(Object key){return containsKey(key)?super.get(key):0L;}
    public void add(T key,long v){put(key,get(key)+v);}
    public void add(T key){put(key,get(key)+1);}
    public void sub(T key){final long v=get(key);if(v==1)remove(key);else put(key,v-1);}
    public MultiSet<T> merge(MultiSet<T> set)
    {MultiSet<T>s,l;if(this.size()<set.size()){s=this;l=set;}else{s=set;l=this;}
        for(Entry<T,Long>e:s.entrySet())l.add(e.getKey(),e.getValue());return l;}
}
 
class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
#define ll long long int
#define ul unsigned long long int
#define pb push_back
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	bool b=true;
	int t[n+1],x[n+1],y[n+1];
	t[0]=0;x[0]=0;y[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
		int p=((t[i]-t[i-1])-((abs(x[i]-x[i-1]))+(abs(y[i]-y[i-1]))));
		if(p%2!=0 || p<0)
			b=false;
	}
	if(b)
		cout<<"Yes";
	else
		cout<<"No";
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
int ctoi(char c){return (int)c-(int)'a';}
int main() {
    string s,t; cin>>s>>t;
    vector<vi> char_pos(26);
    for (int i = 0; i < s.size(); i++){
        char_pos[ctoi(s[i])].push_back(i);
    }
    vi count(26,0);
    vi reset=count;
    int pos=-1;
    ll ans=0;
    for (int i = 0; i < t.size(); i++){
        int ci=ctoi(t[i]);
        if(char_pos[ci].size()==0){
            cout<<-1<<endl;
            return 0;
        }
        while(1){

            count[ci]++;
            if(count[ci]-1==char_pos[ci].size()){
                ans+=s.size()-1-pos;
                ans+=char_pos[ci][0]+1;
                pos=char_pos[ci][0];
                count=reset;
                count[ci]=1;
                break;
            }
            if(char_pos[ci][count[ci]-1]>pos){
                ans+=char_pos[ci][count[ci]-1]-pos;
                pos=char_pos[ci][count[ci]-1];
                break;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4252
def mss(l,length,k):
    x = - 1000000001
    for i in range(length):
        temp = 0
        for j in range(i,i+k):
            temp += l[j]
            if temp > x:
                x = temp
    return x
  
def mss2(l,length,total,k):
    x = - 1000000001
    if k <= length:
      for i in range(length):
          temp = 0
          for j in range(i,i+k):
              temp += l[j]
              if temp > x:
                  x = temp
      return x
    else:
      for i in range(length):
          temp = 0
          for j in range(i,i+length):
              temp += l[j]
              r = j - i + 1
              if temp + (total * ((k-r) // length)) > x:
                  x = temp + (total * ((k-r) // length))
      return x
      

if __name__ == '__main__':
    N,K = map(int,input().split())
    P = [int(p)-1 for p in input().split()]
    C = [int(c) for c in input().split()]
    #閉路の探索
    L_close = []
    Done = [0] * N
    for i in range(N):
        if Done[i] == 1:
            continue
        score = []
        #start
        Done[i] = 1
        #Next
        p = P[i]
        Done[p] = 1
        score.append(C[p])
        while p != i:
            p = P[p]
            Done[p] = 1
            score.append(C[p])
        L_close.append(score)
    #それぞれの閉路に対して
    ans = - 1000000001
    for l in L_close:
        total = sum(l)
        length = len(l)
        l = l + l
        if total <= 0:
            ans = max(ans,mss(l,length,min(K,length)))
        else:
            ans = max(ans,mss2(l,length,total,K))
    print(ans)

Measured memory_bytes: 74520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    double p[n+1],dp[2][n+1],ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i];
    }
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i+j<=n)
            {
                if(i>0&&j>0)
                {
                    dp[i%2][j]=dp[(i-1)%2][j]*p[i+j]+dp[i%2][j-1]*(1-p[i+j]);
                }else if(i>0)
                {
                    dp[i%2][j]=dp[(i-1)%2][j]*p[i+j];
                }else if(j>0)
                {
                    dp[i%2][j]=dp[i%2][j-1]*(1-p[i+j]);
                }else
                {
                    dp[i%2][j]=1;
                }
                if(i>j&&i+j==n)
                {
                    ans+=dp[i%2][j];
                }
            }
        }
    }
    cout<<fixed<<setprecision(10)<<ans;
}


Measured memory_bytes: 384
X = int(input())
list = [1,1000]
C = 2
while True:
    i = 2
    while True:
        n = C**i
        if n >= 1000:
            break
        else:
            list.append(n)
        i += 1
        #print(list)

    C += 1
    if C >= 32:
        break
#print(list)
list = sorted(list)
#print(list)
for i in range(len(list)):
    if list[len(list)-1-i] <= X:
        print(list[len(list)-1-i])
        break

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val N = nextInt()
    val H = listOfInt()
    var ans = 0
    var cnt = 0
    for (n in 0 until N - 1) {
        if (H[n] >= H[n + 1]) cnt++
        else if (cnt > 0) {
            if (ans < cnt) ans = cnt
            cnt = 0
        }
    }
    if (cnt > 0 && ans < cnt) ans = cnt
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

Measured memory_bytes: 57692
#include<stdio.h>
 
int main()
{
	int a, b, c;
		scanf("%d", &a);
		getchar();
		scanf("%d", &b);
		
		if(a==1 && b==2){
			printf("3\n");
		}
		else if(a==2 && b==1){
			printf("3\n");
		}
		else if(a==3 && b==1){
			printf("2\n");
		}
		else if(a==1 && b==3){
			printf("2\n");
		}
		else if(a==3 && b==2){
			printf("1\n");
		}
		else if(a==2 && b==3){
			printf("1\n");
		}
 
	return 0;	
} 

Measured memory_bytes: 1620
#include <bits/stdc++.h>
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))
const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

template <typename T> void print_vec(const vector<T>& v) {
	for(int i = 0; i < SZ(v); i++) {
		if (i) cout << " ";
		cout << v[i];
	}
	cout << "\n";
}

inline ll floorDiv(ll x, ll y) {
	ll d = x / y;
	ll r = x % y;
	return r ? (d - ((x < 0) ^ (y < 0))) : d;
}

ll ceilDiv(ll x, ll y) {
	return -floorDiv(-x,y);
}

bool predicate(ll mid) {
	return mid>10;
}

ll bin_search(ll lo, ll hi) {
	int sign = lo < hi ? 1 : -1;
	lo*=sign;
	hi*=sign;
	hi++;
	while(lo < hi) {
		ll mid = floorDiv(lo+hi,2);
		if (!predicate(sign*mid)) {
			lo = mid+1;
		} else {
			hi = mid;
		}
	}
	return sign*lo;
}
const ll MOD = 1000000007;
const int MAXN = 200005;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int cnt = 0;
	for(int a = 1; a < n; a++){
		for (int b = 1; a*b < n; b++) {
			cnt++;
		}
	}
	cout << cnt << "\n";
	
	
	
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i;
string b;
vector<int> a(4,0);
cin>>n;
for(i=0;i<n;i++)
{
cin>>b;
if(b=="AC")
a[0]++;
else if(b=="WA")
a[1]++;
else if(b=="TLE")
a[2]++;
else if(b=="RE")
a[3]++;
}

cout<<"AC x "<<a[0]<<"\n";
cout<<"WA x "<<a[1]<<"\n";
cout<<"TLE x "<<a[2]<<"\n";
cout<<"RE x "<<a[3]<<"\n";
return 0;
}

Measured memory_bytes: 3612