akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<a.length();i++)
	{
		a[i]=a[i]-32;
	}
	for(int i=0;i<b.length();i++)
	{
		b[i]=b[i]-32;
	}
	for(int i=0;i<c.length();i++)
	{
		c[i]=c[i]-32;
	}
	//string srs=a[0]+b[0]+c[0];
	cout<<a[0]<<b[0]<<c[0];
	return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int64 N, K;
int64 ptoi(int64 y, int64 x) {
  return y * N + x;
}

PLL itop(int64 p) {
  return PLL(p / N, p % N);
}

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

  int64 N, M;
  cin >> N >> M;
  vector<int64> a(N), b(M);
  REP(i, N) cin >> a[i];
  REP(i, M) cin >> b[i];
  auto c = convolution<998244353>(a, b);
  for (auto &x : c) {
    cout << x << " ";
  }
  cout << endl;
}



Measured memory_bytes: 27296
#include <iostream>
#include <vector>
#include<string>
using namespace std;
int main(void){
 
    int A,B,C,D;
 
    
    cin>>A>>B>>C>>D;
    //左//右
    if(A+B > C+D)
    {
        cout<<"Left"<<endl;
    }
    else if(A+B<C+D)
    {
        cout<<"Right"<<endl;
    }else cout<<"Balanced"<<endl;
    
    
   
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    ll A, B, C; cin >> A >> B >> C;
    bool alleven = true;
    if(!(A % 2)) alleven = false;
    if(!(B % 2)) alleven = false;
    if(!(C % 2)) alleven = false;
    cout << (alleven ? min({A*B, B*C, C*A}) : 0LL) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)

H,W = [int(x) for x in input().split()]
S = [list('.'*(W+2))]+[list('.'+input()+'.') for _ in range(H)]+[list('.'*(W+2))]
lix = [-1,0,1,0]
liy = [0,-1,0,1]
flag = True
def dfs(x,y):
    cnt = 0
    if(S[x][y]=='.'):
        return 0
    else:
        cnt += 1
        S[x][y]='.'
        for i in range(4):
            if(S[x+lix[i]][y+liy[i]]!='.'):
                cnt += dfs(x+lix[i],y+liy[i])
        return cnt

for i in range(1,H+1):
    for j in range(1,W+1):
          if(dfs(i,j)==1):
              flag = False
if(flag):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4852
my $s = <STDIN>;
my ($N,$K) = split(/ /,$s);
$s = <STDIN>;
my @dat = split(/ /,$s);
my @h = sort { $b - $a } @dat;
 
if( $N <= $K ){
  print "0\n";exit(0);
}
 
my $sum = 0;
for( my $i = $K ; $i < $N ; $i ++){
  $sum = $sum + $h[$i];
}
print "$sum\n";

Measured memory_bytes: 46624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    double a,b,x;
    cin >> a >> b >> x;
    if(x<=a*a*b/2){
        double tmp = 2*x/(a*b);
        cout << setprecision(20) << 180*atan(b/tmp)/M_PI << endl;
    }
    else{
        double tmp = 2*(a*a*b-x)/(a*a);
        cout << setprecision(20) << 180*atan(tmp/a)/M_PI << endl;
    }
}

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

 int main() {
 int n;
 cin >> n;
 vector<int> p(n);
 rep(i, n) cin >> p[i];
 int k = 0;
 rep(i, n) if(p[i] != i + 1) k++;
 if(k <= 2) cout << "YES" << endl;
 else cout << "NO" << endl;
 return 0;
}

Measured memory_bytes: 256
import Data.List
main = do
  [a,b,c] <- map read . words <$> getLine :: IO [Double]
  putStrLn $ show (ans a b c)

ans :: Double -> Double -> Double -> Double
-- x = c / a
-- (2b-2c/a^2)<b
-- (2c/ab)
ans a b c = if b*a*a < 2*c
                then (atan ((2*b*a*a  - 2 * c) / (a ** 3))) / pi * 180
                else (atan (a*b*b/(2*c))) / pi * 180


Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,y;
  cin >> n >> y;
  for(int i = 0; i<=n; i++){
    for(int j=0; j<=n; j++){
      int k = n-(j+i);
      if(k<0)continue;
      if(10000*i+5000*j+1000*k==y){
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << -1 <<" " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(){
	int n,m;cin>>n>>m;
	set<int> dl;
	int p=0;
	int i=1;
	while(1){
		int a=i+p;
		int b=n-i+1;
		int d1=b-a-1;
		int d2=a-1+n-b;
		if(!dl.count(d1)&&!dl.count(d2)&&d1!=d2){
			cout<<a<<" "<<b<<endl;
			dl.insert(d1);
			dl.insert(d2);
		}else{
			p++;
			continue;
		}
		if(i==m) break;
		i++;
	}
	return 0;
}  


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

int main(){
	double input;
	string s;

	while ( cin >> input ){
		if ( input <= 48.0 ){
			s = "light fly";
		}else if ( input <= 51.0 ){
			s = "fly";
		}else if ( input <= 54.0 ){
			s = "bantam";
		}else if ( input <= 57.0 ){
			s = "feather";
		}else if ( input <= 60.0 ){
			s = "light";
		}else if ( input <= 64.0 ){
			s = "light welter";
		}else if ( input <= 69.0 ){
			s = "welter";
		}else if ( input <= 75.0 ){
			s = "light middle";
		}else if ( input <= 81.0 ){
			s = "middle";
		}else if ( input <= 91.0 ){
			s = "light heavy";
		}else{
			s = "heavy";
		}

		cout << s << endl;
	}

	return 0;
}

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



int main(){
    int n, k; cin >> n >> k;
    vector<ll> x(n),y(n); rep(i,n) cin >> x[i] >> y[i];
    ll ans = 4000000000000000002;
    for(int x1 = 0; x1 < n; ++x1){ // 左端
        for(int x2 = 0; x2 < n; ++x2){ // 右端
            for(int y1 = 0; y1 < n; ++y1){ // 下端
                for(int y2 = 0; y2 < n; ++y2){ // 上端
                    int cnt = 0;
                    for(int i = 0; i < n; ++i){
                        if(x[i] >= x[x1] && x[i] <= x[x2] && y[i] >= y[y1] && y[i] <= y[y2]) cnt++;
                    }
                    if(cnt >= k) ans = min(ans, (y[y2]-y[y1])*(x[x2]-x[x1]));
                }
            }
        }
    }    
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {

	int t,ct1=0,ct2=0,ct3=0,ct4=0;
	scanf("%d",&t);
	char st[4],uff;
	scanf("%c",&uff);
	for(int i=0;i<t;i++)
    {
        scanf("%s",st);
        if(st[0]=='A')
            ct1++;
        if(st[0]=='T')
            ct2++;
        if(st[0]=='R')
            ct3++;
        if(st[0]=='W')
            ct4++;
            if(i<t-1)
            scanf("%c",&uff);
    }
    printf("AC x %d\n",ct1);
    printf("WA x %d\n",ct4);
    printf("TLE x %d\n",ct2);
    printf("RE x %d",ct3);
}








Measured memory_bytes: 1732
package main

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

var scanner = bufio.NewScanner(os.Stdin)


func nextInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getMax(ints []int) int {
	var max int
	max = ints[0]
	for _, v := range ints {
		if max < v {
			max = v
		}
	}
	return max
}

func getMin(ints []int) int {
	var min int
	min = ints[0]
	for _, v := range ints {
		if min > v {
			min = v
		}
	}
	return min
}
func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	a := make([]int, n)
	for i := range a {
		a[i] = nextInt()
	}
	q := nextInt()
	for i := 0; i < q; i++ {
		switch nextInt() {
		case 0:
			// min
			b := nextInt()
			e := nextInt()
			fmt.Printf("%d\n", getMin(a[b:e]))
		case 1:
			// max
			b := nextInt()
			e := nextInt()
			fmt.Printf("%d\n", getMax(a[b:e]))

		default:
			panic("no such operation!")
		}
	}
}


Measured memory_bytes: 1096
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main() {
  long N;
  std::cin >> N;

  std::vector<long> B(N);
  for (long i=0; i<N; i++) {
    long a;
    std::cin >> a;

    B[i] = a - i - 1;
  }
  std::sort(B.begin(), B.end());

  long const median =
    (N%2==1) ? B[N/2] : (B[N/2-1] + B[N/2]) / 2;

  long ans = 0;
  for (auto const b : B) {
    ans += std::abs(b - median);
  }

  std::cout << ans << std::endl;

  return 0;
}


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

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(ll n, ll k) {
  mint x = 1, y = 1;
  for(ll i=0; i<k; i++) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

int main(){
  int n;
  vector<string> v(2);
  cin>>n;
  cin>>v[0];
  cin>>v[1];
  int x = 6;
  int y = 3;
  mint ans = mint(1);
  for(int i=0; i<n; i++) {
    if(i+1<n and v[0][i]==v[0][i+1]) {
      ans*=x;
      x = 3;
      y = 1;
      i++;
    } else {
      ans*=y;
      x = 2;
      y = 2;
    }
  }
  std::cout << ans.x << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int gcd(int a,int b){
    return b==0 ? a:gcd(b,a%b);
}
int main()
{
    int x;
    cin>>x;
    int d=gcd(x,360);
    int h=x*360;
    int c=h/d;
    int p=c/x;
    cout<<p<<endl;
}

Measured memory_bytes: 3584
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	string s;
	cin >> s;
	N = s.size();
	cin >> K;
	K = min(N, K);
	vector<int>v;
	int cnt = 0;
	v.push_back(0);
	for (auto i : s) {
		cnt += i == '1';
		if (i == '0')v.push_back(cnt);
	}
	v.push_back(cnt);
	vector<vector<vector<int>>>dp(v.size(), vector<vector<int>>(cnt * 2 + 1, vector<int>(K + 1)));
	dp[0][0][0] = 1;
	for (int i = 1; i < v.size(); i++) {
		for (int j = 0; j <= cnt; j++) {
			for (int k = 0; k <= K; k++) {
				dp[i][j + v[i] - v[i - 1]][k] += dp[i - 1][j][k];
				dp[i][j + v[i] - v[i - 1]][k] %= MOD;
			}
		}
		for (int j = v[i] + 1; j <= cnt; j++) {
			for (int k = 1; k <= K; k++) {
				dp[i][j][k] += dp[i][j - 1][k - 1];
				dp[i][j][k] %= MOD;
			}
		}
		for (int j = 0; j <= cnt; j++) {
			for (int k = 0; k <= K; k++) {
				for (int l = j; l < j + v[i] - v[i - 1]; l++) {
					dp[i][l][k] += dp[i - 1][j][k];
					dp[i][l][k] %= MOD;
				}
			}
		}
	}
	long long int ans = 0;
		for (int i = 0; i <= K; i++) {
			ans += dp.back()[cnt][i];
	}
	cout << ans % MOD << endl;
}

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

int n, a[200000], b[200000];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i < n; i++) cin >> b[i];
	reverse(b, b + n);
	int l = -1, r = -1;
	for(int i = 0; i < n; i++)
		if(a[i] == b[i]){
			int nl = i, nr = i - 1;
			for(int j = i; a[j] == b[j] && j < n; j++) nr++;
			l = nl, r = nr;
			if(r - l + 1 == n){
				cout << "No\n";
				return 0;
			}
			break;
		}
	if(l != -1){
		int j = l;
		for(int i = 0; i < l && j <= r; i++)
			if(a[i] != b[j] && a[j] != b[i])
				swap(b[i], b[j++]);
		for(int i = r + 1; i < n && j <= r; i++)
			if(a[i] != b[j] && a[j] != b[i])
				swap(b[i], b[j++]);
		if(j <= r){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for(int i = 0; i < n; i++)
		cout << b[i] << " \n"[i == n - 1];
	return 0;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 57;
const int Range = 5050;
const int geta = 2525;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) a[i] -= k;
    
    long long dp[MAX_N][Range] = {0};
    dp[0][geta] = 1;
    
    for (int i = 0; i < n; i++) {
        dp[i+1][geta + a[i]] += 1;
        for (int s = 0; s < Range; s++) {
            dp[i+1][s] += dp[i][s];
            if (0 <= s + a[i] && s + a[i] < Range) {
                dp[i+1][s + a[i]] += dp[i][s];
            }
        }
    }
    
    cout << (dp[n][geta] - 1) / 2 << endl;
    return 0;
}

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

using namespace std;

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

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  while(true){
	int N; cin >> N; if(!N) break;
	vector<PII> pos(N);
	pos[0].first = 0;
	pos[0].second = 0;
	int mx = 0, Mx = 0, my = 0, My = 0;
	for(int i=1;i<N;++i){
	  int n, d; cin >> n >> d;
	  pos[i].first = pos[n].first + dx[d];
	  pos[i].second = pos[n].second + dy[d];
	  mx = min(mx, pos[i].first);
	  Mx = max(Mx, pos[i].first);
	  my = min(my, pos[i].second);
	  My = max(My, pos[i].second);
	}
	//cout << mx <<"," << Mx << " " << my << "," << My << endl;
	cout << Mx - mx + 1 << " " << My - my + 1 << endl;
  }
  
  return 0;
}

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

const int nax = 5e5+5;
vector<long long> st(2*nax);
int n;

void modify(int p, int v) {
	for(st[p+=n] += v;p>0;p>>=1) st[p>>1] = st[p] + st[p^1];
}

long long sum(int l, int r) {
	l+=n, r+=n;
	long long ans = 0;
	while(l<r) {
		if(l&1) ans += st[l++];
		if(r&1) ans += st[--r];
		l>>=1, r>>=1;
	}
	return ans;
}

int main() {
	int q, a, b, t;
	cin >> n >> q;
	for(int i = 0; i < n; i++) {
		st[i] = 0;
		cin >> st[i+n];
	}
	for(int i = n-1;i>0;i--) st[i] = st[2*i]+st[2*i+1];
	while(q--) {
		cin >> t >> a >> b;
		if(!t) {
			modify(a, b);
		}
		else cout << sum(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 12152
N = int(input())
x = []
y = []
h = []
for i in range(N):
    a,b,c = map(int,input().split())
    if c>0: idx_0 = i
    x.append(a)
    y.append(b)
    h.append(c)
for cx in range(101):
    for cy in range(101):
        H = h[idx_0] + abs(x[idx_0]-cx) + abs(y[idx_0]-cy)
        cnt = 0
        for k in range(N):
            if h[k]==max(H - abs(x[k]-cx) - abs(y[k]-cy), 0): cnt+=1
        if cnt==N:
            print(cx,cy,H)
            exit()


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

public class Main {

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int sum = 0;
      
      int offset=0,next=0;
      char regex = ' ';
      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regex,offset)) == -1)
          next = line.length();
        sum += Integer.parseInt(line.substring(offset, next));
        offset = ++next;
      }

      sum -= n;
      System.out.println(sum);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 22996
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

vector<pair<int,int>> G[200010];
ll d[200010];
void dfs(int x,int c){
  // debug(c);
   d[x] = c;
   int m = G[x].size();
   rep(j,m){
      int y = G[x][j].ff;
      if(d[y] == -1){
         dfs(y,c + G[x][j].ss);
      }
   }
}
int main(void){
   int n;cin >> n;
   fill(d,d+n,-1);
   rep(i,n-1){
      int a,b,c;cin >> a >> b >> c;
      a--;b--;
      G[a].pb(mp(b,c));
      G[b].pb(mp(a,c));
   }
   dfs(0,0);
   rep(i,n) d[i] %2 == 0 ? cout << 1 << endl : cout << 0 << endl;
   return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<stack>
#include<string>
using namespace std;
int main()
{
  int x,y,z;
  string str;
  stack<int> a;
  while(cin >> str){
    if(str == "+"){
      x = a.top();
      a.pop();
      y = a.top();
      a.pop();
      z = x + y;
      a.push(z);
    }
    else if(str == "-"){
      x = a.top();
      a.pop();
      y = a.top();
      a.pop();
      z = y - x;
      a.push(z);
    }
    else if(str =="*"){
      x = a.top();
      a.pop();
      y = a.top();
      a.pop();
      z = x * y;
      a.push(z);
    }
    else{
      a.push(stoi(str));
    }
  }
  cout << a.top() << endl;
}

Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int main(){
    int i,ABO[4]={0,0,0,0};
    char abo[10];
    while(scanf("%s",abo)!=EOF){
        for(i=0;;i++){
            if(abo[i]==',') break;
        }
        if(abo[i+1]=='A'&&abo[i+2]=='B'){
            ABO[2]++;
            abo[i+1]='a';
            abo[i+2]='b';
        }
        else if(abo[i+1]=='A'){
            ABO[0]++;
        }
        else if(abo[i+1]=='B'){
            ABO[1]++;
        }
        else if(abo[i+1]=='O'){
            ABO[3]++;
        }
    }
    for(int i=0;i<4;i++){
        printf("%d\n",ABO[i]);
    }
    return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ma;
    ma=max(a,b);
    ma=max(ma,c);
    cout << a+b+c-ma << endl;
    

    return 0;
}

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

using namespace std;
using ll=long long;

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  int a;
  ll cnt=0;
  for(int i=0;i<n;i++){
    cin>>a;
    while(a%2==0){
      a/=2;
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 256
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 2e5+10;

int main()
{
	_SAD()
	 int n,m;
	cin>>n>>m;
        int a;
	long long int  SUM=0;
	rep(i,m)
	{
          cin>>a;
	  SUM+=a;
	}
        if(SUM>=n)
	{
		cout<<"Yes"<<nl;
	}
	else
	   {
		cout<<"No"<<nl;
	   }
	return 0;
}


Measured memory_bytes: 256
/*
 * test1.cpp
 */

//include files
#include<iostream>

using namespace std;

//DEFINE MACROS
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

//DEFINE CONSTANT

//DEFINE PROTOTYPE

int main(){
  string A,B,C;
  cin >> A;
  cin >> B;
  cin >> C;
  if(A[A.length()-1]==B[0] && B[B.length()-1]==C[0]) cout <<"YES"<<endl;
  else cout<<"NO"<<endl;
  
}



Measured memory_bytes: 760
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
#include <limits>
using namespace std;

string ans;
int main(){
    string s1, s2, s3;
    cin >> s1 >> s2 >> s3;
    string next = "a";
    
    while(true){
        if(next == "a"){
            if(s1.size() == 0){
                ans = "A";
                break;
            }
            next = s1[0];
            s1.erase(s1.begin());
        }
        else if(next == "b"){
            if(s2.size() == 0){
                ans = "B";
                break;
            }
            next = s2[0];
            ans = next;
            s2.erase(s2.begin());
        }
        else if(next == "c"){
            if(s3.size() == 0){
                ans = "C";
                break;
            }
            next = s3[0];
            ans = next;
            s3.erase(s3.begin());
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B; cin >> A>>B;
    
    cout << max({A+B,A-B,A*B}) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
int n, t, ans = INT_MAX;

int main() {
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        int ci, ti;
        cin >> ci >> ti;
        if (ti <= t) {
            ans = min(ans, ci);
        }
    }

    if (ans == INT_MAX) {
        cout << "TLE" << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=3e5+10;
int n,a[4][N],a1,a2,b1,b2;

int bit[N];
void add(int x){for (;x;x-=x&-x) bit[x]^=1;}
int qry(int x){int s=0; for (;x<=n;x+=x&-x) s^=bit[x]; return s;}

int main(){
	scanf("%d",&n);
	rep (i,1,3) rep (j,1,n){
		scanf("%d",&a[i][j]);
		if (i>1&&(a[i][j]-1)/3!=(a[i-1][j]-1)/3) return puts("No"),0;
		if (!((((a[i][j]-1)/3)^j)&1)) return puts("No"),0;
	}
	rep (i,1,n) if (a[2][i]!=(a[2][i]-1)/3*3+2) return puts("No"),0;
	rep (i,1,n) if (a[1][i]>a[3][i]) (i&1)?a1^=1:a2^=1;
	for (int i=1;i<=n;i+=2) b1^=qry((a[2][i]-1)/3+1),add((a[2][i]-1)/3+1);
	memset(bit,0,sizeof(bit));
	for (int i=2;i<=n;i+=2) b2^=qry((a[2][i]-1)/3+1),add((a[2][i]-1)/3+1);
	puts((b1==a2)&&(b2==a1)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n;
vector<llong> s;
vector<llong> p, q;
llong a, b;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        llong x;
        cin >> x;
        p.push_back(x);
    }
    for (int i = 0; i < n; i++) {
        llong x;
        cin >> x;
        q.push_back(x);
    }
    for (int i = 1; i <= n; i++) {
        s.push_back(i);
    }

    llong i = 1;
    do {
        if (s == p) a = i;
        if (s == q) b = i;
        i++;
    } while (next_permutation(s.begin(), s.end()));

    cout << llabs(a - b) << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 学籍番号 17D8101029G 石塚 博之 ID: mcatpolo 言語: python3

a,b,c = map(int, input().split())

n = int(0)
i = int(0)

while True:
    i += 1
    n += a
    if i%7 == 0:
        n+=b

    if n >= c:
        break

print(i)


Measured memory_bytes: 5600
#include <stdio.h>
 
 
int main()
{
	int N;
	int i;
	int current;
	int cnt = 0;
 
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &current);
		if ((i + 1) != current) {
			cnt++;
		}
	}
 
	if (cnt > 2) {
		printf("NO\n");
	}
	else {
		printf("YES\n");
	}
    return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
x = list(map(int, input().split()))
s, t = [], []
for i in x:
    if i < 0:
        s.append(abs(i))
    elif i == 0:
        k -= 1
    else:
        t.append(i)
s.append(0)
s.reverse()
t.insert(0, 0)
ans = 1145141919810
for i in range(k + 1):
    if len(s) - 1 >= i and len(t) - 1 >= k - i:
        c = 2 * min(s[i], t[k - i]) + max(s[i], t[k - i])
        if c < ans:
            ans = c
print(ans)

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	vector<pair<int, long long>> BC(M);
	for (int i = 0; i < M; i++) {
		int b;
		long long c;
		cin >> b >> c;
		BC[i] = { b,c };
	}
	sort(A.begin(), A.end());
	sort(BC.begin(), BC.end(),
		[](const pair<int, long long>& a, const pair<int, long long>& b) {
			if (a.second == b.second) return a.first > b.first;
			else return a.second > b.second;
		});
	vector<long long>B(N);
	int b = 0, j = 0;
	long long c = 0;
	for (int i = 0; i < N; i++) {
		if (b == 0) {
			if (j > M - 1) break;
			const auto& bc = BC[j];
			b = bc.first;
			c = bc.second;
			j++;
		}
		B[i] = c;
		b--;
	}
	long long sum = 0;
	for (int i = 0; i < N; i++) sum += max(B[i], A[i]);
	cout << sum << endl;
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N,K;
cin>>N>>K;
int cnt=0;
int h;
rep(i,N){
    cin>>h;
    if(h>=K)cnt++;
}
cout<<cnt<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let z = 1_000_000_007 in
    let ( +@) a b = (a + b) mod z in
    let ( *@) a b = (a * b) mod z in

    let rec loop i d09 d0 d9 dn =
        if i = n then d09 else
            loop (i + 1) (d09 *@ 10 +@ d0 +@ d9) (d0 *@ 9 +@ dn) (d9 *@ 9 +@ dn) (dn *@ 8)
    in
    loop 0 0 0 0 1 |> Printf.printf "%d\n"
)

Measured memory_bytes: 3788
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            boolean flg = false;
            if (s.charAt(0) == 'A') {
                int cnt = 0;
                int at = 0;
                for (int i = 2; i <= s.length() - 2; i++) {
                    if (s.charAt(i) == 'C') {
                        cnt++;
                        at = i;
                    }
                }
                if (cnt == 1) {
                    flg = true;
                    for (int i = 1; i < s.length(); i++) {
                        if (i == at) continue;
                        if (s.charAt(i) < 'a'  || 'z' < s.charAt(i)) {
                            flg = false;
                            break;
                        }
                    }
                }
            }

            System.out.println(flg ? "AC" : "WA");
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
 
  if (a+b>=a-b&&a+b>=a*b)
    cout<<a+b;
  else if(a+b<=a*b&&a-b<=a*b)
    cout<<a*b;
  else if (a-b>=a+b&&a-b>=a*b)
    cout<<a-b;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[200001],b[200001];
int main(){
	int i,j,k,n,m;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		int s1,s2;
		cin>>s1>>s2;
		if(s1==1)a[s2]=1;
		if(s2==n)b[s1]=1;
	}
	for(i=1;i<=m;i++)
	if(a[i]>0&&b[i]>0){
		cout<<"POSSIBLE"<<endl;
		return 0;
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python
# coding: utf-8

def main():
    w, h, n = [int(i) for i in raw_input().split()]
    x_min, x_max, y_min, y_max = 0, w, 0, h
    for _ in range(n):
        x, y, a = [int(i) for i in raw_input().split()]
        if a == 1:
            x_min = max(x_min, x)
        if a == 2:
            x_max = min(x_max, x)
        if a == 3:
            y_min = max(y_min, y)
        if a == 4:
            y_max = min(y_max, y)
    if x_min > x_max:
        print 0
    elif y_min > y_max:
        print 0
    else:
        print (x_max-x_min)*(y_max-y_min)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2692
st=input()
if st=="SUN":
     print("7")
elif st=="MON":
    print("6")
elif st=="TUE":
    print("5")
elif st=="WED":
    print("4")                                                 
elif st=="THU":
    print("3") 
elif st=="FRI":
    print("2") 
elif st=="SAT":
    print("1") 


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int main(){
	int n;
	cin>>n;
	string a;
	cin>>a;
	if(n==0){
		cout<<a;
		return 0;
	}
	for(int i=0; i<a.size(); i++){
		if(char(a[i]+n)<=90 && char(a[i]+n)>=65)
		cout<<char(a[i]+n);
		else{
			cout<<char(65+abs(90-(a[i]+n))-1);
		}
	}
}

Measured memory_bytes: 256
m, n = gets.split.map(&:to_i)
pp = []
n.times { pp << gets.split.map(&:to_i) }

pp.sort_by! { |x| x[1]}

c = 0
b = 0
pp.each { |l, r|
  if l > b
    c += 1
    b = r - 1
  end
}

puts c


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

int main() {
    ll S, n,Min=100000000000;
    vector<ll>x(200000);
    cin>>n;
    rep(i,n){
        cin>>x[i];
        S+=x[i];
    }
    rep(i,n-1) Min=min(Min,abs(S-=2*x[i]));
    cout<<Min<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s;cin >> s;
    ll ans = 0;
    rep(i,s.size()){
        if(s[i] == '?') {
            s[i] = 'D';
        }
    }
    cout << s << endl;
    // cout << ans << endl;
}


Measured memory_bytes: 3752
# -*- coding: utf-8 -*-

n = int(input().strip())
nums = list(map(int, input().rstrip().split()))
#----------
calc=[]
for i in range(len(nums)-1):
    for j in range(i+1,len(nums)):
        calc += [ abs(nums[i] - nums[j]) ]

print(max(calc))


Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <queue>
#define maxn 200005

using namespace std;

struct node{
	int to, next;
}e[maxn << 1];
int head[maxn], tot = 0;
void addedge(int u, int v){e[++tot].to = v, e[tot].next = head[u]; head[u] = tot;}

int n, m, Index[maxn][2];
char str[maxn];

bool vis[maxn];

int topo(){
	queue <int> q; while (!q.empty()) q.pop();
	
	for (int i = 1; i <= n; i++)
		if (!Index[i][0] || !Index[i][1]) q.push(i), vis[i] = true;
	
	int cnt = 0;
	while (!q.empty()){
		int cur = q.front(); q.pop();
		cnt++;
		
		for (int i = head[cur]; i; i = e[i].next){
			if (!vis[e[i].to] && !(--Index[e[i].to][str[cur] - 'A'])){
				q.push(e[i].to);
				vis[e[i].to] = true;
			}
		}
	}
	return cnt;
	
}

int main(){
	scanf("%d%d%s", &n, &m, str + 1);
	
	while (m--){
		int u, v; scanf("%d%d", &u, &v);
		addedge(u, v);
		addedge(v, u);
		Index[v][str[u] - 'A']++;
		Index[u][str[v] - 'A']++;
	}
	
	puts(topo() == n ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
int ques1(int *p,int n,int k){
    int dp[100001]; dp[2]=abs(p[2]-p[1]); dp[1]=0;
    for(int i=3;i<=n;i++){
      int r=INT_MAX,j=1;
      while(j<=k&&(i-j)>=1){
      r=min(dp[i-j]+abs(p[i-j]-p[i]),r);
      j++;
    }
    dp[i]=r;}
    cout<<dp[n];
}
int main() {
	int n,k;
	cin >> n>>k;
	int p[n+1];
	p[0]=0;
	for(int i=1;i<=n;i++){
	    cin >> p[i];
	}
	ques1(p,n,k);
	return 0;
}

Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:i64 = read();
    let mut an =  vec![0];
    an.append(&mut read_vec::<i64>());
    // let mut an = read_vec::<i64>();
    an.push(0);
    let sum:i64 = an.windows(2)
            .map(|t| (t[0]-t[1]).abs())
            .fold(0,|y,x| y+x);
    for j in 1..(n+1) as usize{
        let d1 = (an[j-1]-an[j]).abs();
        let d2 = (an[j]-an[j+1]).abs();
        let cost = (an[j-1]-an[j+1]).abs();
        println!("{}",sum-d1-d2+cost );
    }
}

Measured memory_bytes: 8444
arr = list(input())
k = int(input())

lst = []
for n in range(97, 123):
    for i in range(0, len(arr)):
        if arr[i] == chr(n):
            ge = ""
            for j in range(0, 5):
                if i + j < len(arr):
                    ge = ge + (arr[i + j])
                    if ge not in lst:
                        lst.append(ge)
                else:
                    break
    if len(lst) > 5:
        break
lst.sort()
print(lst[k - 1])


Measured memory_bytes: 3060
#include<stdio.h>

int bs (int [], int, int);

int min(int b,int c)
{
	if(b>=c) return c;
	return b;
}

int main(void)
{
	int i,j,n,a,dp[1000001],dp2[1000001];
	
	for(i=0;i<=1000000;i++)
	{
		dp[i]=i;
		dp2[i]=i;
	}
	for(i=3,a=4;a<=1000000;i++)
	{
		for(j=0;j+a<=1000000;j++)
		{
			dp[j+a]=min(dp[j+a],dp[j]+1);
		}
		
		if(a%2==1)
		{
			for(j=0;j+a<=1000000;j++)
		    {
			    dp2[j+a]=min(dp2[j+a],dp2[j]+1);
	    	}
		}
		a=i*(i+1)*(i+2)/6;
	}
	
	while(1)
	{
		scanf("%d",&n);
		if(n==0) break;
		printf("%d %d\n",dp[n],dp2[n]);
	}
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  unsigned long long int sum = 0;
  int N = (int)s.size();
  for (int tmp = 0; tmp < (1 << N-1); tmp++) {
    bitset<10> a(tmp);
    long x = 0;
    long buf = 0;
    for (int i = 0; i < N; i++) {
      x = x*10 + (s.at(i) - '0');
      if (a.test(i) || i == N-1) {
        buf += x;
        x = 0;
      }
    }
    sum += buf;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        // N/Dの入力
        String[] nums = Console.ReadLine().Split(' ');
        int N = int.Parse(nums[0]);
        int D = int.Parse(nums[1]);
        //座標点の入力
        int answer = 0;
        for(int i = 0;i<N;i++){
            String[] point = Console.ReadLine().Split(' ');
            double x = double.Parse(point[0]);
            double y = double.Parse(point[1]);
            double ans = System.Math.Sqrt(((x * x) + (y * y)));
            if(ans <= D){
                answer++;
            }
        }
        // 結果出力
        Console.WriteLine(answer);
    }
}


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

Measured memory_bytes: 9140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    Func cin2;
    void calc()
    {
        cin = new Scanner();
        cin2 = new Func();
        int[] abcd=cin.ArrayInt(4,0);
        int ac=Math.Abs(abcd[0]-abcd[2]);
        int ab=Math.Abs(abcd[0]-abcd[1]);
        int bc=Math.Abs(abcd[1]-abcd[2]);
        int d=Math.Abs(abcd[3]);
        string ans="No";
        if(ac<=d||((ab<=d)&&(bc<=d)))ans="Yes";
       Console.WriteLine(ans);
        
        
    }
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

class Answer
{
    public void Int2DArrayAns(int[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
    public void Char2DArrayAns(char[,]x,char c)
    {
        for(int i=0;i<x.GetLength(0);i++)
        {
            for(int j=0;j<x.GetLength(1)-1;j++)
            {
                Console.Write(x[i,j]);
                Console.Write(c);
            }
            Console.WriteLine(x[i,x.GetLength(1)-1]);
        }
    }
}

class Func
{
    public long GCDLong(long a, long b)
    {
        while(a!=0)
        {
          long t=a;
          a=b%a;
          b= t;
        }
      
        return b;        
    }
}



Measured memory_bytes: 11220
def gcd(x,y):
    ma = max(x,y)
    mi = min(x,y)
    if mi == 0:
        return ma
    else:
        return gcd(mi,ma%mi)

n = int(input())
a = list(map(int,input().split()))

ans = 0
for i in range(len(a)):
    ans = gcd(ans,a[i])
print(ans)

Measured memory_bytes: 62704
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    ll ans = 0;
    ll add = 0;
    int a[100010], b[100010];
    rep(i, N) cin >> a[i] >> b[i];
    RREP(i, N - 1, 0) {
        ans += (b[i] - (a[i] + add) % b[i]) % b[i];
        add += (b[i] - (a[i] + add) % b[i]) % b[i];
        //cout << ans << " " << add << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024