akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,a[1000005];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
int main()
{
    n=read();
    int mn=n+1,mx=0;
    for(int i=1;i<=n;i++)
    {
        a[i]=read();
        mn=min(mn,a[i]);
        mx=max(mx,a[i]);
    }
    if(mx>mn+1){puts("No");return 0;}
    if(mx==mn)
    {
        if(mn==n-1){puts("Yes");return 0;}
        if(2*mn<=n){puts("Yes");return 0;}
        puts("No");return 0;
    }
    else
    {
        int cnt=0;
        for(int i=1;i<=n;i++)cnt+=(a[i]==mn);
        if(mn<cnt){puts("No");return 0;}
        if(n-cnt<2*(mx-cnt)){puts("No");return 0;}
        else{puts("Yes");return 0;}
    }
    return 0;
}

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


Measured memory_bytes: 2056
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <bitset>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // BEFORE SUBMIT DON'T FORGET TO UNCOMMENT THIS
    int k, n;
    cin >> k >> n;
    vector<int> vec(n+5);
    for(int i = 0; i < n; ++i) cin >> vec[i];
    int ans = 1e9;
    for(int i = 0; i < n; ++i)
    {
        int dprev;
        if(i == 0)
        {
            dprev = k - vec[n-1] + vec[i];
        }
        else
        {
            dprev = vec[i] - vec[i-1];
        }
        int dnxt;
        if(i == n-1)
        {
            dnxt = k - vec[i] + vec[0];
        }
        else
        {
            dnxt = vec[i+1]-vec[i];
        }
        ans = min({ans, k-dprev, k-dnxt});
    }
    cout << ans << "\n";
    return 0; 
}


Measured memory_bytes: 1024
from collections import deque
n, m, p = map(int, input().split())
graph = [[] for _ in range(n+1)]
edge = []
for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a].append((b, c))
    edge.append((a, b, -c+p))

q = deque([])
coins = [0] * (n+1)
ban = [False] * (n+1)

for i in range(1, n+1):
    q.append(i)
    time = [-1] * (n + 1)
    time[i] = 0
    while q:
        now = q.pop()
        for node, coin in graph[now]:
            if time[node] != -1:
                continue
            time[node] = time[now] + 1
            q.append(node)
    if i != 1:
        if time[n] == -1:
            ban[i] = True
    else:
        for j in range(2, n+1):
            if time[j] == -1:
                ban[j] = True


def bellman_ford(v, e_list, start, end):
    inf = 10**9
    dist = [inf] * (v+1)
    dist[start] = 0
    for j in range(v):
        for e in e_list:
            if ban[e[1]]:
                continue
            if dist[e[1]] > e[2] + dist[e[0]]:
                dist[e[1]] = e[2] + dist[e[0]]
                if j == v-1:
                    return -1, 0
    return dist[end], 1


ans, st = bellman_ford(n, edge, 1, n)
if st:
    print(max(-ans, 0))
else:
    print(-1)


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	int h, w;
	cin >> h >> w;
	vector<vector<char>> g(h, vector<char>(w));
	vector<int> r(h), c(w);
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			cin >> g[i][j];
		}
	}
	for(int i = 0; i < h; i++) {
		bool f = true;
		for(int j = 0; j < w; j++) {
			if(g[i][j] == '#') f = false;
		}
		if(f) r[i]++;
	}
	for(int i = 0; i < w; i++) {
		bool f = true;
		for(int j = 0; j < h; j++) {
			if(g[j][i] == '#') f = false;
		}
		if(f) c[i]++;
	}
	for(int i = 0; i < h; i++) {
		if(r[i]) continue;
		for(int j = 0; j < w; j++) {
			if(c[j]) continue;
			cout << g[i][j];
		}
		cout << endl;
	}
	return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int, int> pi;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MKP 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())

const int INF = 999999;
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll MOD = 1000000007;

int dp[1024][1024];
int ans = 0;


int main()
{

	cin.tie(0);
	ios::sync_with_stdio(false);
	char S[4];
	ans = 0;
	cin >> S;
	REP(i,4){
		if (S[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;
	

}

Measured memory_bytes: 256
#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 <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

//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())
#define MT(a,b,c) MP(a, MP(b, c))

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

int u[32][32];
int S[33][33];
PII memo[33][33][33][33];

inline int getSum(int sx,int sy,int ex, int ey){
	return S[ey][ex] - S[ey][sx] - S[sy][ex] + S[sy][sx];
}

PII DFS(int sx,int sy,int ex, int ey, int s){
	if(memo[sx][sy][ex][ey].first != -1)return memo[sx][sy][ex][ey];
	PII ret = MP(-1,-1);
	//縦割り
	FOR(i, sx+1, ex){
		PII ret1 = DFS(sx, sy, i, ey, s);
		PII ret2 = DFS(i, sy, ex, ey ,s);
		if(ret1.first != 0 && ret2.first != 0){
			PII tret = MP(ret1.first+ret2.first, min(ret1.second, ret2.second));
			ret = max(ret, tret);
		}
	}
	//横割り
	FOR(i, sy+1, ey){
		PII ret1 = DFS(sx, sy, ex, i ,s);
		PII ret2 = DFS(sx, i, ex, ey ,s);
		if(ret1.first != 0 && ret2.first != 0){
			PII tret = MP(ret1.first+ret2.first, min(ret1.second, ret2.second));
			ret = max(ret, tret);
		}
	}
	if(ret.first == -1){
		if(getSum(sx,sy,ex,ey) >= s)return memo[sx][sy][ex][ey] = MP(1, getSum(sx,sy,ex,ey) - s);
		else return memo[sx][sy][ex][ey] = MP(0, 0);
	}
	else return memo[sx][sy][ex][ey]=ret;
}

int main(){	
	while(1){
		int h,w,s;
		cin>>h>>w>>s;
		memset(S, 0, sizeof(S));
		memset(memo, -1, sizeof(memo));
		if(h==0)return 0;
		REP(i,h)REP(j,w)scanf("%d", &u[i][j]);
		REP(i,h)REP(j,w)S[i+1][j+1] = S[i][j+1]+S[i+1][j]-S[i][j]+u[i][j];
		PII ret = DFS(0,0,w,h,S[h][w] - s);
		cout << ret.first << " " << ret.second << endl;
	}
}

Measured memory_bytes: 10536
typedef long long int li;
	
	#include<bits/stdc++.h>

	using namespace std;
	
	int main()
	{	
		ios_base::sync_with_stdio(false);
    		cin.tie(NULL);

    		li n;

    		cin>>n;

    		double a[n];

    		for(li i=0;i<n;i++)
    			cin>>a[i];

    		sort(a,a+n);

    		double ans=a[0]+a[1];

    		ans/=2;

    		for(int i=2;i<n;i++)
    		{
    			ans=(ans+a[i])/2;
    		}

    		cout<<ans;

		return 0;
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SORT(i) sort((i).begin(),(i).end())
constexpr int INF = 2000000000;
constexpr int mod = 1000000007;

int main() {
	int N; cin >> N;
	vector<int>a(100000, 0);
	rep(i,N) {
		int b; cin >> b;
		++a[b];
	}
	int ans = 0;
	REP(i, 1, a.size() - 1) {
		ans = max(ans, a[i - 1] + a[i] + a[i + 1]);
	}
	cout << ans << "\n";

	return 0;
}

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

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

	vector<int> L(N);
	rep(i, N) cin >> L.at(i);

	int ans=0;
	rep(i, N-2){
		for(int j=i+1; j<N-1; j++){
			for(int k=j+1; k<N;k++){
				if(L.at(i) != L.at(j) && L.at(j) != L.at(k) && L.at(k) != L.at(i)){
							if(L.at(i) + L.at(j) > L.at(k) && L.at(j) + L.at(k) > L.at(i) && L.at(k) + L.at(i) > L.at(j)) ans++;
						}
			}
		}
	}

	cout << ans << endl;

}



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


int main(){
  int k,s;
  cin >> k >> s;
  int ans = 0;
  REP(x,k+1) {
    REP(y,k+1){
      if ((s-x-y <= k) && (s-x-y >= 0)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>

using namespace std;

int main(){
   int N, A, B;
   cin >> N >> A >> B;
   if( (B-A)%2 == 0 ){
      cout << "Alice" << endl;
   }
   else{
      cout << "Borys"<< endl;
   }
   return 0;
}


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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }
    vector<pair<ll,ll>> p(m);
    for (ll i = 0;i < m;i++){
        cin >> p[i].second >> p[i].first;
    }

    sort(a.begin(), a.end());
    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());

    ll c = 0;

    for (ll i = 0; i < n; i++){
        if (p[c].second == 0){
            c++;
        }

        if (a[i] < p[c].first){
            a[i] = p[c].first;
            p[c].second--;
        }else{
            break;
        }
    }

    ll ans = 0;
    for (ll i = 0; i < n; i++){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 5484
#include <stdio.h>
int main() {
  int a,b,k;
  char s[50]; ;
  scanf("%d %d", &a, &b);
  if ((a+b)%2 == 0){
      k = (a+b)/2;
  } else {
      printf("%s\n", "IMPOSSIBLE");
      return 0;
  }
  printf("%d\n", k);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  vi a(N); rep(i,N) cin >> a[i];

  int f = 0;
  rep(i,N) {
    f += a[i]-1;
  }
  cout << f << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

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;}

const ll INF=1e9+7;

int main()
{
    
    string s;
    cin >> s;
    ll n=s.length();
    vector<bool> ans(n,true);
    ll cnt=0;
    for(ll i=n-1;i>=0;i--){
        if(s[i]=='B'){
            cnt--;
            ans[i]=false;
        }
        else{
            if(cnt<0){
                ans[i]=false;
                cnt++;
            }
        }
    }
    rep(i,n){
        if(ans[i]){
            cout << s[i];
        }
    }
    return 0;
} 

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

struct Card {
	char suit;
	int value;
}; 

void bubble(struct Card A[],int N) {
	bool flag = 1;
	for ( int i = 0; flag; i++) {
		flag = 0;
		for (int j = N - 1; j > i; j--) {
			if (A[j].value < A[j-1].value) {
				swap(A[j],A[j-1]);
				flag = 1;
			}
		}
	} 
}

void selection(struct Card A[],int N) {
	for(int i=0; i<N-1; i++) {
		int minj = i;
		for(int j=i; j<N; j++) {
			if(A[j].value < A[minj].value) minj = j;
		}
		Card t = A[minj]; A[minj] = A[i]; A[i] = t;
	}
}

void print(struct Card A[], int N) {
    for (int i=0; i<N; i++) {
    	if(i>0) cout << " ";
    	cout << A[i].suit << A[i].value;
    }
    cout << endl;
} 

bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i=0; i<N; i++) {
		if ( C1[i].suit != C2[i].suit ) return false; 
		}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;
	
	cin >> N;
	for(int i=0; i<N; i++) {
		cin >> C1[i].suit >> C1[i].value; 
	}
	
	for(int i=0; i<N; i++) {
		C2[i] = C1[i]; 
	}
	
	bubble(C1, N);
	selection(C2, N);
	
    print(C1, N);
    cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}
	 
	return 0;	
}

Measured memory_bytes: 3088
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [r]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    return `${2 * r * 3.1415}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29636
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let mut two_count: Vec<usize> = vec![0; n];
    for i in 1..n {
        let up = n - i;
        let down = i;

        let mut count = two_count[i - 1];
        for i in 0..32 {
            if up & (1 << i) != 0 {
                count += i;
                break;
            }
        }
        for i in 0..32 {
            if down & (1 << i) != 0 {
                count -= i;
                break;
            }
        }

        two_count[i] = count;
    }

    let a = sc
        .read::<String>()
        .chars()
        .map(|c| c as usize - '1' as usize)
        .collect::<Vec<_>>();

    if a.contains(&1) {
        let mut ans = 0;
        for i in 0..n {
            if two_count[i] == 0 {
                ans ^= a[i] & 1;
            }
        }

        println!("{}", ans);
    } else {
        let mut ans = 0;
        for i in 0..n {
            if two_count[i] == 0 {
                ans ^= a[i];
            }
        }

        println!("{}", ans);
    }
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

    using namespace std;
    typedef long long ll;
    typedef vector<ll> vl ;

    #define mp make_pair
    #define pb push_back
    #define f first
    #define s second
    #define all(v) (v).begin(),(v).end()


    const int MOD = 1000000007;
    const int N = 1000005;
    const double PI =4*atan(1);
    const double eps = 1e-7;
    
    ll a[N];
    ll dpu[N],dpd[N];
    ll ans;
    ll n;

    int main(){
        ios::sync_with_stdio(0);
        //freopen("easy.txt","r",stdin);
        cin >> n;
        ans=0;
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        dpu[0]=a[0];
        for(int i=1;i<n;i++){
            dpu[i]=__gcd(a[i],dpu[i-1]);
        }
        dpd[n-1]=a[n-1];
        for(int i=n-2;i>=0;i--){
            dpd[i]=__gcd(a[i],dpd[i+1]);
        }
        ans=max(dpd[1],dpu[n-2]);
        for(int i=1;i<n-1;i++){
            ans=max(ans,__gcd(dpd[i+1],dpu[i-1]));
        }
        cout << ans;
        return 0;
    }
        
    

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for(ll i = 0; i < (ll)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	int n, m;
	cin >> n >> m;
	int a, b;
	a = n / 2;
	b = a + 1;
	vector<bool> sa(n, false);
	rep(i, m) {
		cout << a+1 << ' ' << b+1;
		cout << endl;
		a--;
		b++;
		a %= n;
		b %= n;
		if (2 * abs(a - b) == n) a--;
		a %= n;
		if (sa[abs(a - b)]) b++;
		b %= n;
		sa[abs(a - b)] = true;
		sa[n - abs(a - b)] = true;
	}
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int main(void)
{
	char m[102][102];

	while(1)
	{
		int h,w,x,y;
		scanf("%d%d",&h,&w);
		if(h==0&&w==0)return 0;
		for(y=0;y<h;y++)
			scanf("%s",m[y]);
		x=0;y=0;
		for(;;)
		{
			h=m[y][x];m[y][x]='!';
			if(h=='!')
			{
				puts("LOOP");
				break;
			}
			else if(h=='v') y++;
			else if(h=='^') y--;
			else if(h=='>') x++;
			else if(h=='<') x--;
			else
			{
				printf("%d %d\n",x,y);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 624
#!/usr/bin/env python3
import sys, itertools


def solve(N: int, A: "List[int]"):
    B = list(itertools.accumulate(A))
    S = sum(A)
    mn = 1e12
    for i in range(N-1):
        d = abs(B[i] - (S - B[i]))
        mn = min(d, mn)
    print(mn)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36984
#coding: utf-8
N = int(input())
dp = [0 for _ in range(N)]
h = list(map(int, input().split()))
dp[1] = dp[0] + abs(h[0] - h[1])
for i in range(2, N):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))
print(dp[N-1])

Measured memory_bytes: 14756
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int n[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin>>k;
    cout<<n[k-1]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define FOR(i, a, n) for(int i=a; i<n; i++)
#define RFOR(i, a, n) for(int i=n-1; i>=a; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define INF -100000

int main()
{
	int H;
	while (cin >> H, H) {
		int table[11][5];
		RFOR(i, H, 11) REP(j, 5) table[i][j] = -1;
		RFOR(i, 0, H) REP(j, 5) cin >> table[i][j];

		int ans = 0;
		bool changed = true;
		while (changed) {
			changed = false;

			REP(i, H) {
				int prev = 0;
				int chain = 1, ch = 1;
				int num = 0, jj = -1;
				REP(j, 5) {
					if (table[i][j] == -1 || table[i][j]==INF) {
						prev = 0;
						chain = 1;
						continue;
					}

					if (prev == table[i][j]) {
						chain++;
						if (chain >= 3) {
							num = table[i][j];
							jj = j;
							ch = chain;
						}
					}
					else chain = 1;

					prev = table[i][j];
				}

				chain = max(chain, ch);
				if (chain >= 3) {
					changed = true;

					ans += (num * chain);
					REP(cnt, chain) table[i][jj - cnt] = INF;
				}

			}

			REP(i, H) {
				REP(j, 5) {
					if (table[i][j] == -1) continue;
					else if (table[i][j] == INF) {
						int cnt = 1;
						while (i+cnt<11 && table[i + cnt][j] == INF) {
							cnt++;
						}
						if (i + cnt > 10) continue;
						table[i][j] = table[i + cnt][j];
						table[i + cnt][j] = INF;
					}
				}
			}
		}

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

Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	  if(a==b && b==c)
	    cout<<"No";
    else if(a==b || b == c || a==c)
	 {
	 	cout<<"Yes";
	 	
	 }

     else
         cout<<"No";
}

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

double toRadian(int degree)
{
    return (degree / (180 / M_PI));
}

int main()
{
    int a, b, C;
    scanf("%d%d%d", &a, &b, &C);

    double S, L, h;
    S = (double)(a * b * sin(toRadian(C)) / 2);
    double c = sqrt(pow(a, 2) - 2*a*b*cos(toRadian(C)) + pow(b, 2));
    L = (double)(a + b + c);
    h = (double)(2 * S / a);
    printf("%lf\n%lf\n%lf\n", S, L, h);

    return 0;
}


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

bool DEBUG = false;

/**
* @brief ナップザック問題を解く関数
* @param[in] W(最大容量) 重さの和はこれを超えてはならない
* @param[in] w(重さの配列) それぞれの要素の重さ
* @param[in] v(価値の配列) それぞれの要素の価値
* @return ret(価値の最大値) 価値の総和の最大値
* @details 重さw価値vの荷物がいくつかあり、容量Wのナップザックにどれを入れるか選ぶ。今回は同じ荷物は1度しか入れられない。この時の価値の最大値を求める問題。
*/

int knapsack(int W, vector<int> &w, vector<int> &v){
    int ret = 0;
    int n = w.size();

    // デバッグ出力
    if(DEBUG){
        for(int i = 0; i < n; i++) {
            cout << w[i] << " " << v[i] << endl;
        }
    }

    vector<vector<int> > dp(n);
    for(int i = 0; i < n; i++) {
        dp[i].resize(W+1, 0);
    }

    // 一行目の初期化
    for(int i = 0; i <= W; i++) {
        if(w[0] <= i){
            dp[0][i] = v[0];
        }else{
            dp[0][i] = 0;
        }
    }

    // dp
    for(int i = 1; i < n; i++) {
        for (int j = 0; j <= W; j++){
            if(j - w[i] < 0){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = max(dp[i-1][j - w[i]] + v[i], dp[i-1][j]);
            }
        }
    }

    // デバッグ出力
    if(DEBUG){
        for(int i = 0; i < n; i++) {
            for (int j = 0; j <= W; j++){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
    }
    
    
    ret = dp[n-1][W];
    return ret;
}


/**
* @brief ナップザック問題（重複可）を解く関数
* @param[in] W(最大容量) 重さの和はこれを超えてはならない
* @param[in] w(重さの配列) それぞれの要素の重さ
* @param[in] v(価値の配列) それぞれの要素の価値
* @return ret(価値の最大値) 価値の総和の最大値
* @details 重さw価値vの荷物がいくつかあり、容量Wのナップザックにどれを入れるか選ぶ。今回は同じ荷物をいくつでも入れられる。この時の価値の最大値を求める問題。
*/
int knapsack_duplicate(int W, vector<int> w, vector<int> v){
    int ret = 0;
    int n = w.size();

    int dp[n][W+1];

    // 一行目の初期化
    for(int i = 0; i <= W; i++) {
        if(w[0] <= i){
            dp[0][i] = dp[0][i - w[0]] + v[0];
        }else{
            dp[0][i] = 0;
        }
    }

    //dp
    for(int i = 1; i < n; i++) {
        for (int j = 0; j <= W; j++){
            dp[i][j] = max(dp[i][j - w[i]], dp[i-1][j]); // 重複不可の場合は、dp[i][j - w[i]]をdp[i-1][j - w[i]]にすれば良い。
        }
    }
    
    ret = dp[n-1][W];
    return ret;
}

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

    vector<int> v(N), w(N);
    for(int i = 0; i < N; i++) {
        cin >> v[i] >> w[i];
    }

    int ans = knapsack(W, w, v);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
  
int main(){
 long long  int N,M;
  
  cin>>N>>M;
  
  vector<long long int>A(N);
  vector<long long int>B(N);
  vector<pair<long long int,long long int>>S(N);
  long long int sum=0;
  
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
   S.at(i).first=A[i];
    S.at(i).second=B[i];
  }
  
  sort(S.begin(),S.end());
  
  long long int ans=0;
  
  bool flag=false;
  
  for(int i=0;i<N;i++){
    for(int j=0;j<S.at(i).second;j++){
      ans+=S.at(i).first;
      sum++;
      if(sum>=M){
        flag=true;
        cout<<ans<<endl;
        break;
        
    }
    
    }
    
    if(flag){
      break;
    }
  }
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
int W,H,N,R;
D inf=1e50,eps=1e-9;
inline D cro(P a,P b){
	return imag(conj(a)*b);
}
inline D dot(P a,P b){
	return real(conj(a)*b);
}
inline bool ispal(L a,L b){
	return abs(cro(a.fs-a.sc,b.fs-b.sc))<eps;
}
inline P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+(b.sc-b.fs)*t;
}
inline P perp(L l,P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
inline D dLP(L l,P p){
	return abs(perp(l,p)-p);
}
D a[100],b[100],c[100],d[100],t[104];
vector<L> war,lines;
void init(){
	war.clear();
	lines.clear();
}
bool solve(){
	init();
	rep(i,N){
		cin>>a[i]>>b[i]>>c[i]>>d[i]>>t[i];
		P p=P(a[i],b[i]),q=P(c[i],d[i]);
		war.pb(L(p,q));
		P v=P(b[i]-d[i],c[i]-a[i]);
		v/=abs(v);
		v*=(R+t[i]);
		lines.pb(L(p+v,q+v));
		lines.pb(L(p-v,q-v));
	}
	lines.pb(L(P(R,0),P(R,H)));
	lines.pb(L(P(W-R,0),P(W-R,H)));
	lines.pb(L(P(0,R),P(W,R)));
	lines.pb(L(P(0,H-R),P(W,H-R)));
	war.pb(L(P(0,0),P(0,H)));
	war.pb(L(P(0,H),P(W,H)));
	war.pb(L(P(W,H),P(W,0)));
	war.pb(L(P(W,0),P(0,0)));
	t[N]=t[N+1]=t[N+2]=t[N+3]=0;
	N+=4;
	int M=lines.size();
//	rep(i,M) cout<<lines[i].fs<<" "<<lines[i].sc<<endl;
//	cout<<endl;
	rep(i,M) rep(j,i){
		L la=lines[i],lb=lines[j];
		if(ispal(la,lb)) continue;
		P p=intLL(la,lb);
		if(p.real()<0||p.real()>W||p.imag()<0||p.imag()>H) continue;
//		show(p);
		bool ok=true;
		rep(k,N){
//			cout<<war[k].fs<<" "<<war[k].sc<<endl;
			if(dLP(war[k],p)+eps<t[k]+R){
				ok=false;
				break;
			}
		}
		if(ok) return true;
	}
	return false;
}
int main(){
	while(true){
		cin>>W>>H>>N>>R;
		if(W==0) break;
		cout<<(solve()?"Yes":"No")<<endl;
	}
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   

ll bin(ll a, ll b)
{
    ll res = 1;
    while(b)
    {
        if(b&1) res=((res%mod)*(a%mod))%mod;
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res%mod;
}

ll inv(const ll& a)
{
    return bin(a, mod-2)%mod;
}

ll fact[500005];
ll inverse[500005];

ll ncr(ll n, ll r)
{
    if(r==0 || n==r)
        return 1;

    return ((fact[n]%mod) * (((inverse[r] % mod) * (inverse[n-r]%mod)%mod))%mod)%mod;
}

ll npr(ll n, ll r)
{
    if(n==0 || r==0) return 1;
    return ((fact[n]%mod) * (((inverse[n-r] % mod)%mod))%mod)%mod;
}

int32_t main() 
{ 
    fact[0] = 1;
    for(ll i = 1; i<=500000; ++i) 
        fact[i] = fact[i-1]*i, fact[i] %= mod;
    for(ll i = 0; i<=500000; ++i)
        inverse[i] = inv(fact[i])%mod;
    fastio
    ll n, m;
    cin>>n>>m;  

    ll num1 = npr(m, n);
    ll num2 = npr(m, n);
    ll num3 = 0;  
    ll tot = (num1*num2)%mod;

    for(int i = 1; i<=n; ++i) {
        int mult = 1;
        if(i%2) mult = 1;
        else mult = -1;
        num3 = ((num3) + mult * (((npr(n, i) * ncr(m, i)) % mod) * bin(npr(m-i, n-i), 2)%mod)%mod) % mod;
    }
    num3 %= mod;
    cout<<(tot-num3+mod)%mod<<endl;
}

Measured memory_bytes: 11460
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる






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

  vector<ll> p(n);
  ll ans=0;
  rep(i,n){
    cin>>p[i];
    ans+=abs(p[i]);
  }

  sort(all(p));

  if(p[0]>0) cout << ans-2*p[0] << endl;
  else if (p[n-1]<0) cout << ans+2*p[n-1] << endl;
  else cout << ans << endl;

  int now=n-2;
  while(now>0 && p[now]>=0){
    cout << p[0] << " " << p[now] << endl;
    p[0]-=p[now];
    now--;
    if(now==0) break;
  }

  cout << p[n-1] << " " << p[0] << endl;

  p[n-1]-=p[0];

  now=1;
  while(now<n-1 && p[now]<0){
    cout << p[n-1] << " " << p[now] << endl;
    p[n-1]-=p[now];
    now++;
    if(now==n-1) break;
  }

}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,K,R,S,P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    int ans = 0;

    auto gain = [&](int a,char c){
        if(a==0 && c=='s') return R;
        if(a==1 && c=='p') return S;
        if(a==2 && c=='r') return P;
        return 0;
    };

    for(int k=0;k<K;k++){
        vec<int> dp(3,0);
        for(int i=k;i<N;i+=K){
            vec<int> ndp(3,0);
            for(int a=0;a<3;a++) for(int b=0;b<3;b++) if(a!=b){
                ndp[b] = max(ndp[b],dp[a]+gain(b,T[i]));
            }
            swap(ndp,dp);
        }
        ans += max({dp[0],dp[1],dp[2]});
    }
    cout << ans << endl;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
int N, K;
string S;
vector<int> num(100010, 0);

int main() {
    cin >> N >> K;
    cin >> S;

    int j = 0;

    for(int i = 0; i < N; ++i) {
        if(i == 0) {
            if(S.at(i) == '0') {
                num.at(j) = 0;
                ++j;
                num.at(j) += 1;
            }else {
                num.at(j) += 1;
            }
        }else {
            if(S.at(i) == S.at(i-1)) {
                num.at(j) += 1;
            }else {
                ++j;
                num.at(j) += 1;
            }
        }
    }

    int max = 0;
    int len = j+2;

    int limit = len / 2;

    for(int i = 0; i <= len; i+=2) {
        int sum = 0;
        if(K < limit) {
            if(i + 2 * K < len) {
                for(int j = i; j <= i + 2 * K; ++j) {
                    sum += num.at(j);
                }
                if(max < sum) max = sum;
            }
        }else {
            for(int j = 0; j <= len; ++j) {
                max += num.at(j);
            }
            break;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 896
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = arrayInt(sc, n);
		sc.close();
		long ans = Long.MAX_VALUE;
		for (int i = 0; i < 101; i++) {
			long tmp = 0;
			for (int j = 0; j < n; j++) {
				tmp += ((a[j] - i) * (a[j] - i));
			}
			if (ans > tmp) {
				ans = tmp;
			}
		}
		System.out.println(ans);
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static Integer[] arrayInteger(Scanner sc, int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}

Measured memory_bytes: 22992
r, g, b, n = map(int, input().split())
l = [r, g, b]

dp =[[1, 1, 1]]
for x in range(n):
    dp.append([0, 0, 0])

for i in range(1, n + 1):
    for j in range(3):
        dp[i][j] = 0
        for q in range(j, 3):
            if i - l[q] >= 0:
                dp[i][j] = dp[i][j] + dp[i - l[q]][q]

print(dp[n][0])

Measured memory_bytes: 3436
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string.h>
#include <vector>
#include <cmath>
#include <iostream>
#include <unordered_map>
#include <queue>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void RuinedSquare() {
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int remx = x2 - x1;
	int remy = y2 - y1;
	int y3 = y2 + remx;
	int x3 = x2 - remy;
	int x4 = x3 - remx;
	int y4 = y3 - remy;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << "\n";
}
int main() {
	RuinedSquare();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long   ll;
typedef  long double ld;
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define mod(n, m) (((n % m) + m) % m)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    string s;
    cin >> s;
    s += '3';
    int mx = 0, cnt = 0;
    for(auto c : s){
        if(c == 'R')
            ++cnt;
        else mx = max(mx, cnt), cnt  = 0;
    }
    cout << mx;






}

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

long long MOD = 1000000007;

long long exp(long long a, long long b)
{
    if(b==0)
        return 1;
    else
    {
        if(b%2==0)
        {
            long long x = exp(a,b/2);
            return (x*x)%MOD;
        }
        else
        {
            long long x = exp(a,b/2);
            return (a*((x*x)%MOD))%MOD;
        }
    }
}

int main()
{
    long long N,K;
    cin>>N>>K;
    long long T=N*K+1;


    long long fire[N][T];
    for(long long i=0; i<N; i++)
    {
        for(long long j=0; j<T; j++)
        {
            fire[i][j] = 0;
        }
    }



    if(N==K)
    {
        fire[N-1][1]=1;
        fire[N-1][0] = K;

    }
    else
        fire[N-1][0] = K+1;




    long long x;
    for(long long i=N-2; i>=0; i--)
    {
        for(long long j=0; j<K+1; j++)
        {
            for(long long a=0; a<T; a++)
            {
                if(j>i+1)
                    fire[i][a]=(fire[i][a]+fire[i+1][a])%MOD;
                else
                {
                    x=(j+a)/(i+1);
                    fire[i][a+x] = (fire[i][a+x]+fire[i+1][a])%MOD;
                }
            }
        }
    }


    long long ans = (((exp(K+1,N)*K)%MOD*exp(2,MOD-2))%MOD*N)%MOD;
    for(long long i=0; i<T; i++)
    {
        ans = (ans + i*MOD - fire[0][i]*i)%MOD;
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    if (a >= b && a >= c) {
        cout << (10 * a) + b + c << endl;
    }
    else if (b >= a && b >= c) {
        cout << (10 * b) + a + c << endl;
    }
    else if (c >= a && c >= b) {
        cout << (10 * c) + b + a << endl;
    }

    return (0);
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;
const int MAX_N = 400, MAX_C = 400;
const ll MOD = 1000000007;

ll dp[MAX_N+1][MAX_C+1] = {1};
ll lsw[MAX_N+1][MAX_C+1];

int main() {
	int N, C;
	ll a[MAX_N], b[MAX_N];
	cin >> N >> C;
	for(int i=0;i<N;i++) cin >> a[i];
	for(int i=0;i<N;i++) cin >> b[i];
	for(int i=0;i<=MAX_N;i++) {
		for(int j=0;j<=MAX_C;j++) {
			if(i==0) lsw[i][j] = !!j;
			else lsw[i][j] = lsw[i-1][j] * j % MOD;
		}
	}
	for(int i=0;i<=MAX_N;i++) {
		for(int j=1;j<=MAX_C;j++) {
			lsw[i][j] += lsw[i][j-1];
			lsw[i][j] %= MOD;
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=0;j<=C;j++) {
			for(int k=0;k<=j;k++) {
				ll tmp = lsw[j-k][b[i-1]] - lsw[j-k][a[i-1]-1] + MOD;
				tmp %= MOD;
				dp[i][j] += dp[i-1][k] * tmp;
				dp[i][j] %= MOD;
			}
		}
	}

	cout << dp[N][C] << endl;
	return 0;
}


Measured memory_bytes: 2816
/*{{{*/
#define HOME
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
template<class T, class U> void _R(pair<T, U> &x) {_R(x.F); _R(x.S);}
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }

template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }

template<class T, class... U> void DB(const T &head, const U &... tail) {
#ifdef HOME
    _W('#'); W(head, tail...);
#endif
}

#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define ITER(i,t) for (auto i = t.begin(); i != t.end(); ++i)

#define SZ(x) int((x).size())
#define ALL(x) (x).begin(), (x).end()
#define UNIQUE(x) {sort(ALL(x)); (x).erase(unique(ALL(x)), (x).end());}

#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define MS(X, v) memset((X), (v), sizeof((X)))

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef int64_t ll;
/*}}}*/

int n, y;
int im = 0;

int main(){
    R(n,y);
    int high = y/1000, low = y/10000;

    if(high < n){ W(-1,-1,-1); return 0; }
    int dn = high-n;
    /*
    dn = 9a + 4b
    10a+4b
    */
    REP(i,0,n) REP(j,0,n){
        int k = n-i-j;
        if(k<0 || n<k) continue;
        if(10000*i+5000*j+1000*k!=y) continue;
        W(i,j,k);
        return 0;
    }
    W(-1,-1,-1);
    /*
    if(a==-1) W(-1,-1,-1);
    else{
        W(a,b,n-a-b);
        if(a*10000+b*5000+(n-a-b)*1000!=y) W("GGG");
    }
    // */
    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();
    let cs: Vec<_> = s.chars().collect();
    for (i, (c0, c1)) in cs.iter().zip(cs[1..].iter()).enumerate() {
        if c0 == c1 {
            println!("{} {}", i + 1, i + 2);
            return;
        }
    }

    for (i, (c0, c2)) in cs.iter().zip(cs[2..].iter()).enumerate() {
        if c0 == c2 {
            println!("{} {}", i + 1, i + 3);
            return;
        }
    }

    println!("-1 -1");
}


Measured memory_bytes: 4352
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
from bisect import bisect_left
from itertools import product
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
#文字列を一文字ずつ数字に変換、'5678'を[5,6,7,8]とできる
def LSI(): return list(map(int, list(sys.stdin.readline().rstrip())))
def LSI2(N): return [list(map(int, list(sys.stdin.readline().rstrip()))) for i in range(N)]
#文字列として取得
def ST(): return sys.stdin.readline().rstrip()
def LST(): return sys.stdin.readline().rstrip().split()
def LST2(N): return [sys.stdin.readline().rstrip().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**6+10)

N,K = MI()
P = LI()
temp = 0
for i,v in enumerate(P):
    if i < K-1:
        temp += v
    elif i== K-1:
        temp += v
        ans = temp
    else:
        temp -= P[i-K]
        temp += v
        ans = max(ans,temp)
ans = (ans+K)/2
print(ans)


Measured memory_bytes: 88556
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

char s[233];

bool check(int n){
	for(int i=1;i<=n/2;++i){
		if(s[i]!=s[i+(n/2)])return 0;
	}
	return 1;
}

int n;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=n-2;i;i-=2)if(check(i))return printf("%d\n",i),0;
	return puts("0"),0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define maxn 100000

#define ll long long int



int main(){
	int a,b,c;
	int k;
	cin>>a>>b>>c;
	cin>>k;
	int x1= a/b;
	x1++;
	
	int c1=0;
	int ans=0;
	while(1<<c1<x1){
		c1++;
	}
	ans+=c1;
	int x2= b*(1<<c1)/c;
	x2++;
	c1=0;
	while(1<<c1 < x2){
		c1++;
	}
	ans+=c1;
	if(k>=ans){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}

}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;

int main() {
	int n, h, w; cin >> n >> h >> w;
		cout << (n - h + 1)*(n - w + 1) << endl;
	//stop
		return 0;
}


Measured memory_bytes: 256