akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include <algorithm> 
using namespace std;

# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;

int main()
{
    int n,m,x,y;cin >> n >> m >> x >> y;

    int max_x;cin >> max_x;
    for(int i=0;i<n-1;i++){
        int tmp;cin >> tmp;
        max_x=max(max_x,tmp);
    }
 
    int min_y;cin >> min_y;
    for(int i=0;i<m-1;i++){
        int tmp;cin >> tmp;
        min_y=min(min_y,tmp);
    }

    int flg=false;
    for(int i=x+1;i<=y;i++){
        if(max_x<i && min_y>=i) flg=true;
    }
    printIf(flg,"No War","War")
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 410000, mod = 998244353;

int n, g[N], f[N], ans;
char s[N], tmp[N];

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

inline int addMod(int a, int b) {
    return (a += b) >= mod ? a - mod : a;
}

inline int check(int len) {
    int t = 2 * n / len;
    for (R int i = 0; i < t; ++i) {
        for (R int j = 1; j <= (len >> 1); ++j) tmp[i * len + j] = s[j];
        for (R int j = (len >> 1) + 1; j <= len; ++j) tmp[i * len + j] = s[j - (len >> 1)] ^ 1;
    }
    for (R int i = 1; i <= 2 * n; ++i) {
        if (s[i] < tmp[i]) return 0;
        if (s[i] > tmp[i]) return 1;
    }
    return 1;
}

int main() {
    read(n), scanf("%s", s + 1);
    for (R int i = 1; i <= n; ++i) s[i + n] = s[i] ^ 1;
    for (R int i = 1; i <= n; ++i) {
        f[i] = addMod(f[i - 1], f[i - 1]);
        if (s[i] == '1') f[i] = addMod(f[i], 1);
    }
    for (R int i = 2; i <= 2 * n; i += 2) {
        if (n % i == 0 || 2 * n % i != 0) continue;
        g[i >> 1] = addMod(f[i >> 1], check(i));
        for (R int j = 2; j < i; j += 2)
            if (i % j == 0) g[i >> 1] = addMod(g[i >> 1], mod - g[j >> 1]);
        ans = (ans + (ll) i * g[i >> 1]) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

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

    ll ar[1000006];
    memset(ar , -1 , sizeof(ar));

    for(ll i=3 ; i<1000006 ; i++) {
        if(i%3==0 || i%5==0)
        ar[i] = 0;
    }

    ar[0] = 0;

    for(ll i=1 ; i<=1000000 ; i++) {
        if(ar[i]) {
            ar[i]=i;
            ar[i]+=ar[i-1];
        }
        else {
            ar[i] = ar[i-1];
        }
    }

    ll n;
    cin >> n;
    //cout << n;

    cout << ar[n];
    
    return 0;
}

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

using namespace std;
#define ll long long int
const int MAXN = 2e5 + 10;

int n;
vector<vector<int>> g(2, vector<int>(105));
int dp[3][105];

int rec(int i, int j, int score){
    if( i == 1 and j == n - 1) return score + g[i][j];
    if( i > 1 or i < 0) return -INT_MAX;
    if( j > n - 1 or j < 0) return -INT_MAX;
    int &res = dp[i][j];    

    if(i == 0){
        //go right and down
        res = rec(i, j + 1, score + g[i][j]);
        res = max(res, rec(i + 1, j, score + g[i][j]));
    } else {
        //go right
        res = max(res, rec(i, j + 1 , score + g[i][j]) );
    }
    return res;
}

void solve(){
    cin >> n;
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            cin >> g[i][j];
        }
    }

    int res = rec(0, 0, 0);
    cout << res << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}


Measured memory_bytes: 256
//for(int i=0;i<n;i++)cin>>arr[i];
//for(int i=0;i<n;i++)cout<<arr[i]<<" ";

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int arr[n];
  int total=0;
  for(int i=0;i<n;i++){cin>>arr[i];total+=arr[i];}
  //cout<<total;
  int cnt=0;
  int temp=4*m;
  int temp2=ceil((float)total/temp);
  //cout<<temp2;
  for(int i=0;i<n;i++)
  {
  	if(arr[i]>=temp2)
      cnt++;
  }
  if(cnt>=m)cout<<"Yes";
  else if(cnt!=m)cout<<"No";
  return 0;
}

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

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

int main() {
	int n; cin >> n;
	vector<int> a(n);

	REP( i, n ) cin >> a[i];
	REP( i, n - 1 ) cout << a[i] << " ";
	cout << a[n - 1] << endl;

	for( int i = 1; i < n; i++ ) {
		int tmp = a[i];

		int j;
		for( j = i - 1; j >= 0; j-- ) {
			if( a[j] > tmp ) {
				a[j + 1] = a[j];
			} else {
				break;
			}
		}
		a[j + 1] = tmp;

		REP( i, n - 1 ) cout << a[i] << " ";
		cout << a[n - 1] << endl;
	}

}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main(){
  int n ;
  cin>>n ;
  ll ans=0;
  ll last= 0;
  ll a;
  for(int i = 0; i< n ; i++){
      cin>>a;
      last=max(last,a);
      ans+=max(0ll,last-a);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<algorithm>
#include <iostream>
using namespace std;
typedef long long LL;

int main(){
	LL n,m;
	while(~scanf("%lld %lld",&n,&m)){
		if(n > m/2){
			printf("%lld\n",m/2);
		}
		else{
			LL ans = n;
			m = m-2*n;
			ans = ans+m/4;
			printf("%lld\n",ans);
		}
	}
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();

    if (n <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0, k) + "..." << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 5;

int main(){
	int a,b;
	scanf("%d%d", &a,&b);
	int x = a + b, y = a*b, z = a - b;
	cout << max({ x, y, z }) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a=new int[101];
		while(sc.hasNextInt()){
			int b=sc.nextInt();

			a[b]++;
		}

		int max=0;
		for(int i=1; i<=100; i++){
			if(a[i]>=max){
				max=a[i];

			}
		}
		for(int i=1; i<=100; i++){
			if(a[i]==max){
				System.out.println(i);
			}
		}
	}

}



Measured memory_bytes: 26256
#include<stdio.h>


int main()
{
int n;
int x=0;
int y=0;
char a[100];
scanf("%d",&n);
scanf("%s",a);
for(int i=0;i<n;i++){
if(a[i]=='('){
x++;
}else{
y++;
if(x>=1){
x--;
y--;
}
}
}
for(int i=0;i<y;i++){
printf("(");
}
printf("%s",a);
for(int i=0;i<x;i++){
printf(")");
}
return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000

int main(){
  int N; cin >> N;
  vector<pair<int,int>> cood(N);
  int v[N];
  rep(i,N){
    cin >> cood[i].first >> cood[i].second;
  }
  double dist_mean = 0;
  int per=0;

  sort(all(cood));
  do{
    pair<int,int> p0 = cood[0];
    for (auto p : cood){
      dist_mean += sqrt((p.first-p0.first)*(p.first-p0.first) + (p.second-p0.second)*(p.second-p0.second));
      p0 = p;
      //cout << p.first << " " << p.second << endl;
    }

    per++;
  }while(next_permutation(all(cood)));

  //per = per/(N+1);
  cout << fixed << setprecision(10);
  cout << dist_mean/per << endl;


}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

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

double cross(const xy_t &a, const xy_t &b){
	return imag(conj(a) * b);
}

double dot(const xy_t &a, const xy_t &b){
	return real(conj(a) * b);
}

xy_t projection(const line &l, const xy_t &p){
	double t = dot(p - l.first, l.first - l.second) / norm(l.first - l.second);
	return l.first + t * (l.first - l.second);
}

bool intersectSP(const line &l, const xy_t &p){
	return abs(l.first- p) + abs(l.second - p) - abs(l.first - l.second) < EPS;
}

double distanceSP(line s, xy_t p){
	const xy_t r = projection(s, p);
	if(intersectSP(s, r)) return abs(r - p);
	return min(abs(s.first - p), abs(s.second - p));
}

int main(){
	char res[1000];
	int n, pos, ind;
	string s;
	cin >> n;
	rep(t, n){
		cin >> s;
		fill(res, res + 1000, '?');
		int sz = s.size();
		ind = 1;
		pos = 500;
		res[pos] = s[0];
		while(ind < sz){
			char a = s[ind+1];
			char b = s[ind+2];
			ind += 3;
			if(a == '>') pos++;
			else pos--;
			res[pos] = b;
		}
		rep(i, 1000) if(res[i] != '?') cout << res[i];
		cout << endl;
	}
}

		

Measured memory_bytes: 0
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/detail/ceil_and_floor.hpp
#ifndef DETAIL_CEIL_AND_FLOOR_HPP
#define DETAIL_CEIL_AND_FLOOR_HPP

namespace tools {
  template <typename T>
  constexpr T floor(T lhs, T rhs);

  template <typename T>
  constexpr T ceil(T lhs, T rhs);

  template <typename T>
  constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T>
  constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/ceil.hpp
#ifndef CEIL_HPP
#define CEIL_HPP


/*
usage:

tools::ceil(5, 3) // => 2 (i.e., ceil(5 / 3))
*/

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> a;
  tools::read(a, N);

  // 1以上の長さを持つaの区間のうち、中央値がx以上である区間の数
  const auto f = [&](const i64& x) {
    std::unordered_map<i64, i64> map;
    i64 result = 0;
    i64 sum = 0;
    i64 border = 0;

    for (const i64& a_i : a) {
      if (a_i >= x) {
        --border;
        sum += map[border];
        ++map[border + 1];
        ++sum;
        result += sum;
      } else {
        ++border;
        sum -= map[border - 1];
        ++map[border - 1];
        result += sum;
      }
    }

    return result;
  };

  i64 ok = *std::min_element(a.begin(), a.end());
  i64 ng = *std::max_element(a.begin(), a.end()) + 1;
  while (ng - ok > 1) {
    const i64 center = (ok + ng) / 2;
    if (f(center) >= tools::ceil<i64>(N * (N + 1), 4)) {
      ok = center;
    } else {
      ng = center;
    }
  }

  std::cout << ok << std::endl;
  return 0;
}

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

int main ()
{
    int num1 , num2 , maxm = 0 , minm = 0 ;

    cin >> num1 ;
    cin >> num2 ;

    maxm = max(num1 , num2 ) ;
    minm = min(num1 , num2 ) ;
    int res = 0 ;
    if (maxm < 3)
        res = maxm + minm ;
    else if (maxm == 3)
        res = maxm - minm ;

    cout << res ;
    return 0  ;
}


Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_A
# Stack
# Result:
import sys

class Stack:
    def __init__(self):
        self.store = []

    def push(self, item):
        self.store.append(item)

    def pop(self):
        if self.is_empty():
            return None
        return self.store.pop()

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False

    def __str__(self):
        """Show top to bottom"""
        val = ''
        for e in reversed(self.store):
            val += str(e) + ' '
        return val

def calculate(stack, func):
    v2 = stack.pop()
    v1 = stack.pop()
    return func(v1, v2)

items = sys.stdin.readline().rstrip().split(' ')
stack = Stack()

for e in items:
    if e == '+':
        v = calculate(stack, lambda v1, v2: v1 + v2)
    elif e == '-':
        v = calculate(stack, lambda v1, v2: v1 - v2)
    elif e == '*':
        v = calculate(stack, lambda v1, v2: v1 * v2)
    else:
        # numbers
        v = int(e)
    stack.push(v)

print stack.pop()

Measured memory_bytes: 4252
x = 1
i = 0
j = 0
card = [[0 for a in range (13)]  for b in range (4)]
checknum = int(input())
while x <= checknum: #????????????????????\???
	picture, num = input().split()
	num = int(num)
	if picture == 'S':
		card[0][num - 1] = num
	if picture == 'H':
		card[1][num - 1] = num
	if picture == 'C':
		card[2][num - 1] = num
	if picture == 'D':
		card[3][num - 1] = num
	x += 1
# index = [(i, j)for i, mini_card in enumerate(card) for j, elem in enumerate(mini_card) if elem == 0]
for i, mini_card in enumerate(card):
	for j, elem in enumerate(mini_card):
		if elem == 0:
			if i == 0:
				i = str('S')
			elif i == 1:
				i = str('H')
			elif i == 2:
				i = str('C')
			elif i == 3:
				i = str('D')
			j += 1
			print(i, j)
# print (card)

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

int main() {
  int a, b, c, d, n, count;
  while(cin >> n) {
    count = 0;
    for(a = 0; a < 10; a++)
      for(b = 0; b < 10; b++)
        for(c = 0; c < 10; c++)
          for(d = 0; d < 10; d++)
            if(a+b+c+d == n) count++;
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;
//https://atcoder.jp/contests/abc167/tasks/abc167_c


int a[12][12];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i, n) {
    cin >> c[i];
    rep(j, m) {
      cin >> a[i][j];
    }
  }
  int ans = INF;
  rep(s, 1 << n) {
    int cost = 0;
    vector<int> now(m);
    rep(i, n) {
      if(s >> i & 1) {
        cost += c[i];
        rep(j, m) {
          now[j] += a[i][j];
        }
      }
    }
    bool ok = true;
    rep(j, m) if(now[j] < x) ok = false;
    if(ok) ans = min(ans, cost);
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3668
// Problem : A - Darker and Darker
// Contest : AtCoder - AtCoder Grand Contest 033
// URL : https://atcoder.jp/contests/agc033/tasks/agc033_a
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
	int H,W;
 inline bool isValid(int x,int y)
 {
 	if(x>=0 && x<H && y>=0 && y<W)
 		return true;
 	return false;
 }
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	cin>>H>>W;
	vi vis[H],sps[H];
	queue<pi> st;
	vi v[H];
	F0R(x,H)
	{
		string str;
		cin>>str;
		F0R(y,W)
		{
			if(str[y]=='#')
				st.push({x,y}),v[x].pb(1);
			else
				v[x].pb(0);
			vis[x].pb(0);
			sps[x].pb(0);
		}
	}
	while(sz(st)!=0)
	{
		pi S=st.front();
		st.pop();
		F0R(x,4)
		{
			pi val={S.f+dx[x],S.s+dy[x]};
			if(isValid(val.f,val.s) && !vis[val.f][val.s] && !v[val.f][val.s])
			{
				vis[val.f][val.s]=1;
				sps[val.f][val.s]=1+sps[S.f][S.s];
				st.push({val.f,val.s});
			}
		}
	}
	int mx=INT_MIN;
	F0R(x,H)
	{
		F0R(y,W)
		{
			ckmax(mx,sps[x][y]);
		}
	}
	cout<<mx;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 23952
//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 20;

int A[maxN];

int main() {
	int n, m, c = 0, s = 0; cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int x; cin >> x;
		string v; cin >> v;
		if(A[x] == -2) continue;
		if(v == "AC") c++, s += A[x], A[x] = -2;
		else A[x]++;
	}
	cout << c << " " << s;
}


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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s, t; cin >> s >> t;
	int n = s.length();
	for (int i = 0; i < n; i++) {
		bool f = true;
		for (int j = 0; j < n; j++)
			if (s[j] != t[(i + j) % n]) {
				f = false;
				break;
			}
		if (f) {
			cout << "Yes" << '\n';
			return 0;
		}
	}
	cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pll pair<long long, long long >
#define ll long long
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define maxn 1000000007
#define endl '\n'
#define trace(x) cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
int mod(int x,int y)
{
  int s;
  s = abs(x)/y;
  if(x<0)s--;
  return x-y*s;
}
int dir8[2][8] = {{1,-1,0,0,1,-1,1,-1},{0,0,1,-1,1,-1,-1,1}};
int dir4[2][4] = {{1,-1,0,0},{0,0,1,-1}};
int m,n,row,col;
char g[1006][1006];
int level[1006][1006];
int memo[1006][1006];
int dp(int x,int y)
{
  if(x == row-1 && y == col-1)return 1;
  int p1=0,p2=0;
  if(memo[x][y]!=-1)return memo[x][y];
  if(x+1 < row && g[x+1][y] =='.')p1 = dp(x+1,y)%maxn;
  if(y+1 < col && g[x][y+1] =='.')p2 = dp(x,y+1)%maxn;
  memo[x][y] = (p1+p2)%maxn;
  return memo[x][y];
}
void solve()
{
  scanf("%d%d",&row,&col);
  for(int w=0;w<row;w++)
  {
    scanf("%s",g[w]);
  }
  memset(memo,-1,sizeof memo);
  int ans = dp(0,0);
  printf("%d\n",ans);

}
void test()
{
  int t;
  //scanf("%d",&t);
  t = 1;
  for(int test=1;test<=t;test++)
  {
    solve();
  }
}
int main()
{
  test();
  return 0;
}


Measured memory_bytes: 7168
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
    }
    
    if k == 1 || n == k {
        println!("0");
    } else {
        println!("{}", n - k);
    }
}


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

#define SZ(x) (int)((x).size())
#define xx first
#define yy second
#define pii pair<int, int>

const int N = 101;

int a[2][N];

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < 2; j++)
            cin >> a[j][i];
    bool w = 0;
    for (int i = 1; i < n - 1; i++) {
        bool t = 1;
        for (int j = -1; j <= 1; j++)
            t &= a[0][i + j] == a[1][i + j];
        w |= t;
    }
    cout << (w ? "Yes" : "No") << '\n';
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 3600
//
// Created by yamunaku on 2019/08/04.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max(c-(a-b),0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}
bool isPrime(int a){
	if(a <=1) return false;
	for(int i=2 ; i*i<=a; i++){
		if(a%i == 0) return false;
	}

	return true;
}
int main(){
	int a; cin >> a;

	while(1){
		if(isPrime(a)){
			cout << a << endl;
			return 0;
		}
		++a;
	}

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define rep(n, i) Rep(0, n-1, i)

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef std::priority_queue<int> IntPrioQueue; //Z->A
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue; //A->Z

const int MAX = 128;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const int MOD = 1000000007;

vector <ll> val[4];
vector <ll> valacc[4];
int cnt[4];

void solve(void){
    int N; ll W, w0, v0;
    cin >> N >> W;
    scanf("%lld %lld\n", &w0, &v0);
    val[0].push_back(v0);
    cnt[0]++;
    rep(N-1, meaningless_) {
        ll w, v;
        scanf("%lld %lld\n", &w, &v);
        val[w-w0].push_back(v);
        cnt[w-w0]++;
    }
    rep(4, i) sort(val[i].rbegin(), val[i].rend());
    rep(4, i) {
        valacc[i].push_back(0LL);
        rep(cnt[i], c) valacc[i].push_back(val[i][c]);
        rep(cnt[i]+1, c) valacc[i][c+1] += valacc[i][c];
    }
    ll ans = 0LL;
    rep(cnt[0]+1, i) {
        if (w0 * i > W) break;
        rep(cnt[1]+1, j) rep(cnt[2]+1, k) rep(cnt[3]+1, l) {
            if (w0 * (i+j+k+l) + j + 2*k + 3*l > W) continue;
            ans = max(ans, valacc[0][i]+valacc[1][j]+valacc[2][k]+valacc[3][l]);
        }
    }
    cout << ans << '\n';
}

int main(void){
  solve();
  return 0;
}


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

int n, m;
int par[100000], ran[100000];
int p[100000], ans = 0;

void init(int n) {
	for (int i = 0; i < n; i++) {
		par[i] = i;
		ran[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (ran[x] < ran[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (ran[x] == ran[y])ran[x]++;
	}
}

int main() {
	cin >> n >> m;
	init(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		unite(x-1, y-1);
	}

	for (int i = 0; i < n; i++) {
		//cout << "i:" << i << " p[i]:" << p[i] << endl;
		if (find(i) == find(p[i]-1)) {
			ans++;
		}
	}

	cout << ans << endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

int n;
int b[44],c[44];
string d[44][44];
vector<int> g[44];
int dame[44];
ll ans=0,sum=0;

void dfs(int v,ll ns){
  if(v==n){
    maxch(ans,ns);
    return ;
  }
  
  ll asum=0;
  repl(i,v,n){
    if(!dame[i])asum+=b[i];
  }
  if(asum+ns<=ans)return ;
  
  if(dame[v]==0){ // use
    dame[v]++;
    for(int nv:g[v]){
      dame[nv]++;
    }
    dfs(v+1,ns+b[v]);
    for(int nv:g[v]){
      dame[nv]--;
    }
    dame[v]--;
  }
  // unuse
  dfs(v+1,ns);
  return ;
}

int main(){
	cin.sync_with_stdio(false);
  while(1){
    rep(i,44)g[i].clear();
    map<string,int> idx;
    cin>>n;
    if(n==0)break;
    ans=sum=0;
    rep(i,n){
      string name;
      cin>>name>>b[i]>>c[i];
      idx[name]=i;
      sum+=b[i];
      rep(j,c[i]){
        cin>>d[i][j];
      }
    }
    rep(i,n){
      rep(j,c[i]){
        int nv=idx[d[i][j]];
        g[i].pb(nv);
        //printf("(%d %d)\n", i,nv);
      }
    }
    memset(dame,0,sizeof(dame));
    dame[0]++;
    for(int v:g[0]){
      dame[v]++;
    }
    dfs(1,0);
    cout<<ans+b[0]<<endl;
  }
	return 0;
}

Measured memory_bytes: 3308
#define rep(i,X) for(i=0;i<X;i++)
n,d[200][3],c[101][3],s[200],i;main(j){scanf("%d",&n);rep(i,n)rep(j,3){scanf("%d",d[i]+j);c[d[i][j]][j]++;}rep(i,3)rep(j,n)if(c[d[j][i]][i]==1)s[j]+=d[j][i];rep(i,n)printf("%d\n",s[i]);return 0;}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N;
	cin >> N;
	vl a(N);
	ll ax = 0;
	rep(i, N) {
		cin >> a[i];
		ax = ax ^ a[i];
	}
	rep(i, N) {
		ll ans = ax ^ a[i];
		cout << ans << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 4744
#include<stdio.h>
int main(){

   int A,B,C,D;

   scanf("%d%d%d%d",&A,&B,&C,&D);

   if((A * B) >= (C * D)){
      printf("%d\n",A*B);
   }else{
      printf("%d\n",C*D);
   }

   return 0;
}

Measured memory_bytes: 128
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	int isSquare(int n) {
		for (int i = (int)Math.sqrt(n); i*i <= n; i++) {
			if (i*i == n) return i;
		}
		return -1;
	}
	
	void run() {
		int a = sc.nextInt();
		for (int i = 0; i < a; i++) {
			int p = sc.nextInt(), q = sc.nextInt();
			int pq2 = p*p+q*q;
			if (pq2 <= 1) {
				out.println("C");
			} else {
				boolean flag = false;
				J:for (int j = 2; j*j <= pq2; j++) {
					if (pq2 % j == 0) {
						for (int m = 0; m*m <= j; m++) {
							int n;
							if ((n=isSquare(j-m*m)) > 0) {
								if ((m*p+n*q)%(m*m+n*n) == 0 && (m*q-n*p)%(m*m+n*n) == 0) {
									flag = true;
									break J;
								}
							}
						}
					}
				}
				if (flag) out.println("C");
				else out.println("P");
			}
			
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 20576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<int Mod> class ModInt {
  int v;
public:
  constexpr ModInt(const long long x = 0) noexcept : v((x % Mod + Mod) % Mod) {};
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    v += rhs.v;
    if (v >= Mod)
      v -= Mod;
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (v < rhs.v)
      v += Mod;
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    v = int(1LL * v * rhs.v % Mod);
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1)
        *this *= rhs;
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  constexpr ModInt operator-() const noexcept { return ModInt(-v); }
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr bool operator==(const ModInt rhs) const noexcept {
    return v == rhs.v;
  }
  constexpr bool operator!=(const ModInt rhs) const noexcept {
    return v != rhs.v;
  }
  constexpr ModInt pow(long long exp) const noexcept {
    ModInt res(1), mul(v);
    while (exp) {
      if (exp & 1)
        res *= mul;
      mul *= mul;
      exp >>= 1;
    }
    return res;
  }
  friend ostream &operator<<(ostream &os, const ModInt obj) noexcept {
    return os << obj.v;
  }
  friend istream &operator>>(istream &is, ModInt &obj) noexcept {
    long long tmp;
    is >> tmp;
    obj = ModInt<Mod>(tmp);
    return is;
  }
};
constexpr int MOD = 1000000007;
using mint = ModInt<MOD>;

const int MAX = 2000100;
long long fac[MAX], finv[MAX], inv[MAX];
void init_comb() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long comb(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  init_comb();
  int n, k;
  cin >> n >> k;
  mint ans = 0;
  rep(i, min(k+1, n)) {
    mint res = 1;
    int rem = n-i;
    res *= comb(n, i);
    res *= comb(i+rem-1, i);
    ans += res;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 47104
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int i;
  int n;
  cin>>n;
  for(i=0;n>1;++i){
    if(0){
    }else if(n/3*3==n){
      n/=3;
    }else if(n/3*2+n/3+1==n){
      n=n/3+1;
    }else if(n/3+(n/3+1)*2==n){
      n=n/3+1;
    }
  }
  cout<<i<<endl;
  return 0;
}

Measured memory_bytes: 0
from collections import deque
K = int(input())
q = deque(range(1, 10))
for _ in range(K - 1):
    x = q.popleft()
    y = x % 10
    if y != 0:
        q.append(10 * x + y - 1)
    q.append(10 * x + y)
    if y != 9:
        q.append(10 * x + y + 1)
ans = q.popleft()
print(ans)

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

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

  map<string, int> mp;
  mp["SUN"] = 7;
  mp["MON"] = 6;
  mp["TUE"] = 5;
  mp["WED"] = 4;
  mp["THU"] = 3;
  mp["FRI"] = 2;
  mp["SAT"] = 1;

  cout << mp[S] << endl;
  return 0;
}

Measured memory_bytes: 256
import numpy as np

s = input().strip()
dp = np.zeros((len(s), 2), dtype=np.int)

# 初期値
dp[0][0] = 1
dp[0][1] = 0
dp[1][0] = 2 if s[0] != s[1] else 0
dp[1][1] = 1

for i in range(2, len(s)):
    d00 = dp[i - 1][0] + 1 if s[i] != s[i - 1] else -1
    d01 = dp[i - 1][1] + 1
    dp[i][0] = max(d00, d01)

    if i >= 3:
        d10 = dp[i - 2][0] + 1
        d11 = dp[i - 2][1] + 1 if s[i-1:i+1] != s[i-3:i-1] else -1
    else:
        d10 = dp[i - 2][0] + 1
        d11 = -1
    dp[i][1] = max(d10, d11)

ans = max(dp[-1][0], dp[-1][1])
print(ans)


Measured memory_bytes: 16100
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string a, b, c, d; cin >> a >> b;
	c = b; d = a;
	reverse(begin(c), end(c)); reverse(begin(d), end(d));
	
	if(a == c and b == d) printf("YES\n");
	else printf("NO\n");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int b[110000];
int c[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
	}
	long long tot=0;
	for(int i=0;i<a;i++)tot+=b[i];
	long long tt=(long long)a*(a+1)/2;
	if(tot%tt){
		printf("NO\n");return 0;
	}
	tot/=tt;
	b[a]=b[0];
	long long cnt=0;
	for(int i=0;i<a;i++)c[i]=b[i+1]-b[i];
	for(int i=0;i<a;i++){
		long long q=tot-c[i];
		if(q%a||q<0){
			printf("NO\n");return 0;
		}
		cnt+=q/a;
	}
	if(cnt==tot)printf("YES\n");else printf("NO\n");
}


Measured memory_bytes: 896
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    const N = S.length;
    
    // 次がDならPにした方が良い
    // for(let i=0; i<N; i++) {
    //     if(S[i] !== "?") continue;
        
    //     if(i === 0) {
    //         if(S[i+1] === "P") {
    //             S[i] = "D";
    //         } else {
    //             S[i] = "P";
    //         }
    //     }
        
    //     if(S[i+1] === "?") {
    //         S[i] = "P";
    //         continue;
    //     }
        
    //     S[i] = "D";
    // }
    
    console.log(S.map(n=>n === "?" ? "D" : n).join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll a, b;
    cin >> a >> b;
    cout << a - (b < a) << endl;
    return 0;
}


Measured memory_bytes: 3600
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  [w,h,n] <- getl $ wrds toInt
  solve w h <$> replicateM n (getl $ toPoint . wrds toInt) >>= print

solve :: Int -> Int -> [Point] -> Int
solve w h xs = sum $ map f $ zip xs (tail xs)
  where
    f :: (Point,Point) -> Int
    f ((x0,y0), (x1,y1))
      | (x0 <= x1 && y0 >= y1) || (x0 >= x1 && y0 <= y1) = dx + dy
      | otherwise = let d = min dx dy in dx + dy - d
      where
        dx = abs (x0 - x1)
        dy = abs (y0 - y1)
        
toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

type Point = (Int,Int)
toPoint :: [Int] -> Point
toPoint [x,y] = (x,y)

Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define N 5050
using namespace std;
const int mod = 1e9 + 7;

inline int fsp(int x, int k = mod - 2) {
    int res = 1;
    while (k) {
        if (k & 1) res = 1ll * res * x % mod;
        x = 1ll * x * x % mod, k >>= 1;
    }
    return res;
}

int n, p[N], sz[N], f[N][N], vis[N], t;
vector<int> G[N];

void dfs(int u, int r) {
    vis[u] = 1;
    if (r < 0) sz[-r]++;
    for (int v : G[u])
        if (v != r) dfs(v, r);
        else ++t;
}

int main() {
#ifdef isLOCAL
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> n;
    for (int i = 1; i <= n; ++i) {
        scanf("%d", p + i);
        if (~p[i]) G[p[i]].push_back(i);
    }

    int K = 0;
    for (int i = 1; i <= n; ++i)
        if (p[i] == -1) dfs(i, -(++K));
    for (int i = 1; i <= n; ++i)
        if (!vis[i]) dfs(i, i);

    int ans = 1ll * t * fsp(n - 1, K) % mod;

    f[0][0] = 1;
    for (int i = 1; i <= K; ++i) {
        f[i][0] = 1;
        for (int j = 1; j <= i; ++j)
            f[i][j] = (f[i - 1][j] + 1ll * f[i - 1][j - 1] * sz[i]) % mod;
    }

    if (K) ans = (ans + 1ll * (f[K][1] - K) * fsp(n - 1, K - 1)) % mod;
    for (int i = 2, j = 1; i <= K; ++i) {
        j = 1ll * j * (i - 1) % mod;
        ans = (ans + 1ll * f[K][i] * j % mod * fsp(n - 1, K - i)) % mod;
    }

    ans = (1ll * n * fsp(n - 1, K) - ans) % mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 70808
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, lim;
    cin >> n >> lim;
    int ans = M;
    for(int i = 0; i < n; i++){
        int c, t;
        cin >> c >> t;
        if(t <= lim){
            ans = min(ans, c);
        }
    }
    if(ans == M){
        cout << "TLE" << '\n';
    }else{
        cout << ans << '\n';
    }
}


Measured memory_bytes: 256
A,B,C,K=map(int,input().split())
l=[A,B,C]
#l.sort(reverse=True)
if K%2==0:
    if abs(A-B)>10**18:
        print("Unfair")
    else:
        print(A-B)
else:
    if abs(B-A)>10**18:
        print("Unfair")
    else:
        print(B-A)



Measured memory_bytes: 38384
using System;
using System.Linq;

namespace Algo
{
    class Program
    {
        static bool check(long x)
        {
            var s = x.ToString();
            return s.Contains('7') & s.Contains('5') & s.Contains('3');
        }
        static long dfs(long x, long n)
        {
            long ret = 0;
            if (x > n) return 0;
            if (check(x)) ret++;
            ret += new[] {7, 5, 3}.Sum(i => dfs(x * 10 + i, n));
            return ret;
        }
        
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine()!);
            Console.WriteLine(dfs(0, n));
        }
    }
}


Measured memory_bytes: 35700
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int n;
	cin >> n;
	string s = to_string(n);
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		sum += (int)(s[i] - '0');
	}
	if (n%sum == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define co cout
#define ci cin
#define sf1(n) scanf("%lld",&n);
#define sf2(n,m) scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define en cout<<endl;
#define pb push_back
#define coy cout<< "YES"<<endl;
#define con cout<< "NO"<<endl;
#define For(a,b) for(ll a=0;a<b;a++)
#define br break;
#define i64 long long
i64 M=10000000;
//ll b[805],ans[805];
map< ll,pair<ll,ll> >mp;

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,res,c1,x,y,c2;
    //co<< 'A'+3;
    ci>>n;
    string a,b,c;
    ci>>a;
    for(ll i=0;i<a.size();i++)
    {
        if((a[i]+n)>'Z') a[i]=((a[i]+n)-'Z')+64;
        else
            a[i]=(a[i]+n);
    }
    co<<a;

}



Measured memory_bytes: 256