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

const int MAX_V = 101;
int match[2][MAX_V];
bool visited[MAX_V];

bool dfs(int u, const vector<int> *G){
	if( u == -1 ) return true;
	
	for(int i=0 ; i < G[u].size() ; i++ ){
		int v = G[u][i];
		
		if( !visited[v] ){
			visited[v] = true;
			if( dfs(match[1][v], G) ){
				match[0][u] = v;
				match[1][v] = u;
				return true;
			}
		}
	}
	return false;
}

int matching(int N, vector<int> *G){
	for(int i=0 ; i < N ; i++ ){
		match[0][i] = match[1][i] = -1;
	}
	
	int res = 0;
	for(int u=0 ; u < N ; u++ ){
		for(int v=0 ; v < N ; v++ ){
			visited[v] = false;
		}
		if( dfs(u, G) ) res++;
	}
	return res;
}

int main(){
	int N;
	cin >> N;
	
	vector<int> X(N);
	for(int i=0 ; i < N ; i++ ){
		cin >> X[i];
	}
	
	int ans_size;
	{
		vector<int> G[MAX_V];
		for(int u=0 ; u < N ; u++ ){
			for(int v=0 ; v < N ; v++ ){
				if( u == v ) continue;
				if( X[u] % X[v] == 0 ){
					G[u].push_back( v );
				}
			}
			ans_size = N - matching(N, G);
		}
	}
	
	vector<int> ans;
	for(int k=0 ; k < N ; k++ ){
		bool flag = true;
		for(int i=0 ; i < ans.size() ; i++ ){
			if( X[ans[i]] % X[k] == 0 || X[k] % X[ans[i]] == 0 ){
				flag = false;
			}
		}
		if( !flag ) continue;
		ans.push_back( k );
		
		vector<int> v;
		for(int i = k+1 ; i < N ; i++ ){
			bool flag = true;
			for(int j=0 ; j < ans.size() ; j++ ){
				if( X[ans[j]] % X[i] == 0 || X[i] % X[ans[j]] == 0 ){
					flag = false;
				}
			}
			if( flag ){
				v.push_back( X[i] );
			}
		}
		
		vector<int> G[MAX_V];
		for(int i=0 ; i < v.size() ; i++ ){
			for(int j=0 ; j < v.size() ; j++ ){
				if( i == j ) continue;
				if( v[i] % v[j] == 0 ){
					G[i].push_back(j);
				}
			}
		}
		if( ans.size() + (v.size() - matching(v.size(), G) ) < ans_size ){
			ans.pop_back();
		}
	}
	
	for(int i=0 ; i < ans.size() ; i++ ){
		if( i ) cout << " ";
		cout << ans[i]+1;
	}
	cout << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > A(n, vector<int>(n, 0));
    for(int i=0; i<n; ++i){
        int k;
        cin >> k;
        // 1~n???index?????¨????????????????????????????????????1????????????0~n-1????????????
        k -= 1;
        int u;
        cin >> u;
        for(int j=0; j<u; ++j){
            int v;
            cin >> v;
            v -= 1;
            A[k][v] = 1;
        }
    }
    
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i][j];
            if(j != n-1)
            cout << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(i,j,n) for (ll i=j;i<(n);i++)
#define RREP(i,n,j) for (ll i = n; j<i;i--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1000000007;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  string S;cin>>S;
  int s_l=S.size();
  int num=1;
  vector<int> ans(s_l,0);
  REP(i,1,s_l){
    if(S.at(i)=='L'){
      ans[i-1]+=ceil((1.)*(num)/2);
      ans[i]+=num/2;
      num=0;
    }
    if(S.at(i)=='R'){
      num++;
    }
  }
  num=1;
  RREP(i,s_l-2,-1){
    if(S.at(i)=='R'){
      ans[i+1]+=ceil((1.)*(num)/2);
      ans[i]+=num/2;
      num=0;
    }
    if(S.at(i)=='L'){
      num++;
    }
  }
  REP(i,0,s_l){
    print(ans[i])
  }
}


Measured memory_bytes: 1488
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <utility>
#include <set>
#include <bitset>
#define ls x<<1
#define rs x<<1|1
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(x) scanf("%d", &x)
#define scdd(x,y) scanf("%d%d", &x, &y)
#define scddd(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define eb emplace_back
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define IOS std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppp;

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 2*acos(0.0);
const double eps = 1e-13;
const ll mod = 998244353;
const int maxn = 2e5 + 10;
const int maxm = 50000 + 10;

int a[maxn], stmin[maxn][50], stmax[maxn][50], tmp[maxn];

void init(int n) {
    for (int i = 0; i < n; i++)
        stmin[i][0] = a[i], stmax[i][0] = a[i];

    for (int j = 1; (1 << j) <= n; j++) {
        for (int i = 0; i + (1 << j) - 1 < n; i++){
            stmin[i][j] = min(stmin[i][j - 1],stmin[i + (1 << (j - 1))][j - 1]);
            stmax[i][j] = max(stmax[i][j - 1],stmax[i + (1 << (j - 1))][j - 1]);
        }
    }
}

int qmin(int l, int r) {
    int k = (int)(log((double)(r - l + 1)) / log(2.0));
    return min(stmin[l][k],stmin[r - (1 << k) + 1][k]);
}

int qmax(int l, int r) {
    int k = (int)(log((double)(r - l + 1)) / log(2.0));
    return max(stmax[l][k],stmax[r - (1 << k) + 1][k]);
}

int d[maxn];
int lowbit(int x) {
    return x&(-x);
}

void add(int x, int k) {
    while(x<maxn) {
        d[x]+=k;
        x += lowbit(x);
    }
}

int query(int x) {
    int sum=0;
    while(x>0) {
        sum += d[x];
        x -= lowbit(x);
    }
    return sum;
}

void solve() {
    int n, k;
    scdd(n, k);
    for(int i=0; i<n; i++) scd(a[i]), a[i]++;
    init(n);
    int now=0;
    for(int i=0; i<k-1; i++) {
        add(a[i], 1);
        now += i+1-query(a[i]);
    }
    int ans=0, flag=0;
    bool first=1;
    for(int i=k-1; i<n; i++) {
        add(a[i], 1);
        now += k-query(a[i]);
        if(!flag){
            if(now==0){
                if(first) ans++;
                first=0;
            }
            else ans++;
        }
        now -= query(a[i-k+1])-1;
        add(a[i-k+1], -1);
        if(i<n-1) {
            if(qmin(i-k+1, i+1)==a[i-k+1] and qmax(i-k+1, i+1)==a[i+1]){
                flag=1;
            }
            else flag=0;
        }
    }
    printf("%d\n", ans);
}

int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("ans.txt","w",stdout);
#endif
    //IOS;
    solve();

    return 0;
}


Measured memory_bytes: 80000
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}

ll dp[200001][5];

int main(int argc, char const* argv[])
{
  int l;
  cin >> l;
  vector<ll> a(l);
  rep(i, l)cin >> a[i];
  rep(i, l + 1){
    rep(j, 5)dp[i][j] = linf;
  }
  dp[0][0] = 0;
  rep(i, l){
    ll curr = dp[i][0];
    dp[i+1][0] = min(dp[i+1][0], curr + a[i]);
    curr = min(curr, dp[i][1]);
    if(a[i] != 0)dp[i+1][1] = min(dp[i+1][1], curr + (a[i] % 2));
    else dp[i+1][1] = min(dp[i+1][1], curr + 2);
    curr = min(curr, dp[i][2]);
    dp[i+1][2] = min(dp[i+1][2], curr + (1 - a[i] % 2));
    curr = min(curr, dp[i][3]);
    if(a[i] != 0)dp[i+1][3] = min(dp[i+1][3], curr + (a[i] % 2));
    else dp[i+1][3] = min(dp[i+1][3], curr + 2);
    curr = min(curr, dp[i][4]);
    dp[i+1][4] = min(dp[i+1][4], curr + a[i]);
    rep(j, 5){
      //cout << i << " " << j << " " << dp[i+1][j] << endl;
    }
  }
  ll res = linf;
  rep(j, 5)res = min(res, dp[l][j]);
  cout << res << endl;
	return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int res = 0;
	FOR(i, 0, 3000) {
		FOR(j, 0, 3000) {
			if (r*i + g * j > n) {
				continue;
			}
			else {
				int tmp = n - r * i - g * j;
				if (tmp%b == 0)res++;
			}
		}
	}
	pv(res)
	return 0;
}

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

#include <math.h>
#include <stdlib.h>


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

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> c(9);
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a > 3200) a = 3200;
        a/=400;
        c[a]++;
    }

    int cmin = 0;
    int cmax = 0;
    for(int i = 0; i < 8; i++){
        if(c[i] != 0){
            cmin++;
            cmax++;
        }
    }

    cmax += c[8];

    if(c[8] == n) cmin = 1;

    cout << cmin << " " << cmax << endl;

    return 0;
}


Measured memory_bytes: 256
void main() {
    int[] a = new int[5];
    foreach (i; 0 .. 5) {
        a[i] = readln.chomp.to!int;
    }
    int k = readln.chomp.to!int;
    writeln(a[$-1] - a[0] > k ? ":(" : "Yay!");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.container;
import std.typecons;

Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	int K;
	cin >> K;

	int A[1000001] = {};

	int kari = 7 % K;
	int kazu = 1;

	while (kari && A[kari] == 0) {
		A[kari] = 1;
		kari = (kari * 10 + 7) % K;
		kazu++;
	}

	if (kari == 0) {
		co(kazu);
	}
	else {
		co(-1);
	}

	Would you please return 0;
}

Measured memory_bytes: 7548
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;
int main(){
  int n;
  string s;
  cin>>s;
  if(s=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(s=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, input().split())
H = list(map(int, input().split()))

adj = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

ans = 0
for v in range(N):
    for u in adj[v]:
        if H[v] <= H[u]:
            break
    else:
        ans += 1
print(ans)



Measured memory_bytes: 29848
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
ab = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    a, b = ab[i][0] - 1, ab[i][1] - 1
    edge[a].append(b)
    edge[b].append(a)

def f(now):
    vi[now] = True
    for to in edge[now]:
        if (now == a and to == b) or (now == b and to == a):
            pass
        else:
            if vi[to] != True:
                f(to)

ans = 0
for s in ab:
    a = s[0] - 1
    b = s[1] - 1
    vi = [False] * N
    f(0)
    for v in vi:
        if not v:
            ans += 1
            break

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
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; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
map<string,ll> x;
int main(){
    ll n,ans=0;
    cin>>n;
    string s;
    rep(i,0,n){cin>>s;x[s]++;}
    cout<<x.size();
    
}


Measured memory_bytes: 19152
#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    int B[n] = {};
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        B[a]++;
    }

    /*
    2の(中央までの個数分)累乗
    奇数の場合でも中央は固定なので偶奇関係なし
    */
    long long ans = 1;
    for(int i = 0; i < n / 2; i++){
        ans  = ans * 2 % MOD;
    }

    /*
    奇数：0が1つ
    偶数：0無し
    */
    if(n & 1){
        if(B[0] == 1);
        else ans = 0;
    }else{
        if(B[0]) ans = 0;
    }

    /*
    奇数：偶数番目に2かどうか確認　…　ex.) 4-2-0-2-4
    偶数：奇数番目に2かどうか確認　…　ex.) 3-1-1-3
    */
    for(int i = 1; i < n; i++){
        if(n & 1){
            if(i & 1){
                if(B[i]){
                    ans = 0;
                    break;
                }
            }else{
                if(B[i] == 2);
                else{
                    ans = 0;
                    break;
                }
            }
        }else{
            if(i & 1){
                if(B[i] == 2);
                else{
                    ans = 0;
                    break;
                }
            }else{
                if(B[i]){
                    ans = 0;
                    break;
                }
            }
        }
    }
    cout << ans << endl; 

    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string s;
	cin >> s;
	cout << (set<char>(all(s)).size() == 1 ? "No" : "Yes") << endl;



	return 0;
}

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

int main(){
  int64_t N,H;
  cin >> N >> H;
  priority_queue<int64_t> pqa,pqb;
  int64_t ans=0;
  for(int i=0;i<N;i++){
    int64_t a,b;
    cin >> a >> b;
    pqa.push(a);
    pqb.push(b);
  }
  while(pqb.top()>pqa.top()){
    H-=pqb.top();
    pqb.pop();
    ans++;
    if(H<=0){
      cout << ans << endl;
      return 0;
    }
    if(pqb.empty()){
      break;
    }
  }
  int64_t count=0;
  count=H/pqa.top();
  if(H%pqa.top()!=0){
    count++;
  }
  ans+=count;
  cout << ans << endl;
  return 0;
}


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

int main(void)
{
    //input
    int n,r1[100],r2[100];
    cin >> n;

    for(int i=0; i<n; i++) cin >> r1[i];
    for(int i=0; i<n; i++) cin >> r2[i];

    //calculate
    int ans = 0;  
    int cntr1 = 0;  
    for(int i = 0; i < n; i++){
        cntr1 += r1[i];
        int cntr2 = 0;
        for(int j = i; j < n; j++){
            cntr2+=r2[j];
        }
    ans = max(ans, cntr1 + cntr2); 
    }
    //output
    printf("%d\n", ans);
}

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

int main() {
  ll n;
  cin >> n;
  map<int, int> factor;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      factor[i] += 1;
      n /= i;
    }
  }
  if (n != 1)
    factor[n] += 1;
  int ans = 0;
  for (auto x : factor) {
    for (int i = 1; i <= x.second; i++) {
      x.second -= i;
      ans += 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
#a,b=map(int,input().split())
#p_3,p_4=map(int,input().split())
n=int(input())
#S=input()
#T=input()
#recipe=[list(input().split())for _ in range(n)]
#m=int(input())
#have=[list(input().split())for _ in range(m)]
#s=[list(input())for _ in range(n)]
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
#c=list(map(float,input().split()))
#n=int(input())
#s=[list(map(int,input().split()))for _ in range(n)]
#s=[list(input().split())for _ in range(n)]
#s=[input()for _ in range(n)]
total=sum(b)
for i in range(n-1):
    if a[i]+1==a[i+1]:
        total+=c[a[i]-1]
print(total)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i]>>c[i];
    int dp[n][3];
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    for(int i=1;i<n;i++){
        dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
        dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;
}

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

int main() {
  int N, res = 100000;
  cin >> N;
  for (int i = 0; i <= N; i++) {
    int A = i, B = 0;
    while (A != 0) {
      B += A % 9;
      A /= 9;
    }
    A = N - i;
    while (A != 0) {
      B += A % 6;
      A /= 6;
    }
    res = min(res, B);
  }
  cout << res;
  return 0;
}

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

using namespace std;
typedef long long ll;
const ll mod=(1e9+7);
const ll inf=(1ll<<61);
const int MX=3e5+9;
int t,a[MX],b[MX],ans;
int main(){
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>a[i];
    }
    for(int i=0;i<t;i++){
        cin>>b[i];
        ans+=max(0,a[i]-b[i]);
    }
    cout<<ans<<endl;
}


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

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

    bool exist = false;
    for (int i = 0; i < S.size(); ++i) {
        for (int j = i + 1; j < S.size(); ++j) {
            if (S[i] == S[j]) {
                exist = true;
                break;
            }
        }
        if (exist) break;
    }

    if (exist) cout << "no" << endl;
    else cout << "yes" << endl;
}

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

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

    rep(i, s.size()) {
        s[i] += n;
        if(s[i] > 90) s[i] -=26;
    }
    cout << s <<  endl;
    return 0;
}


Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include<bits/stdc++.h>
#define pb push_back
#define MAX 300
#define pi 3.1415926536
#define ip pair<int,int>
#define mp make_pair
#define ss second
#define ff first
#define ull unsigned long long
#define ll long long
#define MOD 1000000000
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fn(i,n) for (ll i=0; i<n; i++)
#define endl "\n"
#define Endl endl
#define EN cout<<endl;
#define inp(n) int n; cin>>n;
#define TEST int t; cin>>t; while(t--)
ll power(ll x, ll y, ll p) { int res = 1; x = x % p;  while (y > 0) { if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p;} return res; } 
ll PO(ll a, ll n) { ll val=1; fn(i,n) val*=a; return val;  }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) { return (a.second < b.second); }
 
signed main ()
{
    inp(k); inp(x);

    for (int i=x-k+1; i<=x+k-1; i++)
        cout<<i<<" ";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

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

		string s;
	map<string,int> cnt;
	rep(i,N){
		cin>>s;
		cnt[s] ++;
	}
	cout<<"AC x "<<cnt["AC"]<<endl;
	cout<<"WA x "<<cnt["WA"]<<endl;
	cout<<"TLE x "<<cnt["TLE"]<<endl;
	cout<<"RE x "<<cnt["RE"]<<endl;
	return 0;
}

Measured memory_bytes: 3632
#!/usr/bin/env ruby

n = STDIN.gets.chomp.to_i
nums = STDIN.gets.chomp.split(' ').map &:to_i

if nums.include? 0
  puts nums.inject(0){|s, i| s+i.abs }
  exit
end

if nums.inject(1){|s, i| s * i / i.abs } > 0
  puts nums.inject(0){|s, i| s+i.abs }
else
  min = nums.map(&:abs).min
  puts nums.inject(0){|s, i| s+i.abs } - 2*min
end



Measured memory_bytes: 10380
from heapq import heappush, heappop
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

INF = float('inf')  ###
maxMoney = 2502  ### *2?
#maxMoney = 20

N, M, S = map(int, input().split())
adjL = [[] for _ in range(N)]
for _ in range(M):
    u, v, coin, tm = map(int, input().split())
    u, v = u-1, v-1
    adjL[u].append((v, coin, tm))
    adjL[v].append((u, coin, tm))
moneys, tms = [], []
for _ in range(N):
    money, tm = map(int, input().split())
    moneys.append(money)
    tms.append(tm)

# 単一始点最短経路を求める（Dijkstra法）
def Dijkstra(adjList):
    numV = N * (maxMoney+1)
    numUsed = 0
    costss = [[INF]*(maxMoney+1) for _ in range(N)]
    costss[0][S] = 0
    PQ = []
    heappush(PQ, (0, 0, S))
    while PQ:
        cNow, vNow, moneyNow = heappop(PQ)
        if cNow > costss[vNow][moneyNow]: continue
        numUsed += 1
        if numUsed == numV: break
        for v2, coin, tm in adjList[vNow]:
            if moneyNow < coin: continue
            c2 = cNow + tm
            m2 = moneyNow - coin
            if c2 < costss[v2][m2]:
                costss[v2][m2] = c2
                heappush(PQ, (c2, v2, m2))
        c2 = cNow + tms[vNow]
        m2 = moneyNow + moneys[vNow]
        if m2 > maxMoney:
            m2 = maxMoney
        if c2 < costss[vNow][m2]:
            costss[vNow][m2] = c2
            heappush(PQ, (c2, vNow, m2))
    return costss

S = min(S, maxMoney)
costss = Dijkstra(adjL)
#for i in range(N):
#    print(i, costss[i])

anss = [min(costss[t]) for t in range(1, N)]
print('\n'.join(map(str, anss)))


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;

  if(s.size()==3)reverse(rng(s));
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 3101.cc: Shortest Crypt
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] >= 'A' && s[i] <= 'M') y--;
    else if (s[i] >= 'N' && s[i] <= 'Z') y++;
    else if (s[i] >= 'a' && s[i] <= 'm') x--;
    else if (s[i] >= 'm' && s[i] <= 'z') x++;
  }

  printf("%d\n", abs(x) + abs(y));
  while (y < 0) putchar('A'), y++;
  while (y > 0) putchar('N'), y--;
  while (x < 0) putchar('a'), x++;
  while (x > 0) putchar('n'), x--;
  putchar('\n');
  return 0;
}



Measured memory_bytes: 3328
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

    ll a, b, c, k; cin>>a>>b>>c>>k;

    ll ans = 0;
    if(k <= a){
        ans += k;
    }
    else if(k <= a + b){
        ans += a;
    }
    else{
        ans += a - (k - a - b);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

//
#define MN 10010
struct edge{int to;ll cap,cost;int rev;
edge(int to,ll cap,ll cost,int rev):to(to),cap(cap),cost(cost),rev(rev){}};
vector<edge> g[MN];
int V_mcf,prevv[MN],preve[MN];
ll h[MN],dist[MN];

void init(int V){
	V_mcf=V;
	rep(i,V)g[i].clear();
}

void add_edge(int from,int to,ll cap,ll cost){
	g[from].pb(edge(to,cap,cost,sz(g[to])));
	g[to].pb(edge(from,0,-cost,sz(g[from])-1));
};

ll min_cost_flow_neg(int s,int t,ll f){
	ll res=0;
	fill(h,h+V_mcf,0);
	while(f>0){
		fill(dist,dist+V_mcf,INF);
		dist[s]=0;
		while(1){
			bool update=0;
			rep(i,V_mcf)rep(j,sz(g[i])){
				edge& e=g[i][j];
				if(e.cap>0 && dist[e.to]>dist[i]+e.cost+h[i]-h[e.to]){
					dist[e.to]=dist[i]+e.cost+h[i]-h[e.to];
					prevv[e.to]=i;
					preve[e.to]=j;
					update=1;
				}
			}
			if(!update)break;
		}
		
		if(dist[t]==INF)return INF*INF;
		rep(v,V_mcf)h[v]+=dist[v];
		ll d=f;
		for(int v=t;v!=s;v=prevv[v]){
			d=min(d,g[prevv[v]][preve[v]].cap);
		}
		f-=d;
		res+=d*h[t];
		for(int v=t;v!=s;v=prevv[v]){
			edge& e=g[prevv[v]][preve[v]];
			e.cap-=d;
			g[v][e.rev].cap+=d;
		}
	}
	return res;
}
//

int n,W[111][111],E[111][111];
char c[111][111];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>n;
	rep(i,n)rep(j,n)cin>>W[i][j];
	rep(i,n)rep(j,n)cin>>E[i][j];
	rep(i,n)cin>>c[i];
	init(n*2+2);
	int s = n*2, t = s+1;
	rep(i,n){
		add_edge(s, i, 1, 0);
		add_edge(n+i, t, 1, 0);
	}
	int ans = 0;
	rep(i,n)rep(j,n){
		if(c[i][j] == '.'){
			add_edge(i, n+j, 1, W[i][j]);
		}else{
			ans += E[i][j];
			add_edge(i, n+j, 1, -E[i][j]);
		}
	}
	ans += min_cost_flow_neg(s,t,n);
	cout<<ans<<endl;
	vector<pair<pi,string>> v;
	rep(i,n)rep(j,sz(g[i])){
		int to = g[i][j].to - n;
		if(!(to >= 0 && to < n))continue;
		if(c[i][to] == '.' && g[i][j].cap == 0){
			v.pb(mp(mp(i+1,to+1),"write"));
		}
		if(c[i][to] == 'o' && g[i][j].cap == 1){
			v.pb(mp(mp(i+1,to+1),"erase"));
		}
	}
	cout<<sz(v)<<endl;
	rep(i,sz(v)){
		cout<<v[i].fir.fir<<" "<<v[i].fir.sec<<" "<<v[i].sec<<endl;
	}
}

Measured memory_bytes: 2580
function Main(input) {
    var input = input.split('\n').map(n => parseInt(n, 10));
    var n = input[0];
    var k = input[1];
    var result = 1;
    for(i = 1; i <= n; i++) {
        var double = result * 2;
        var addk = result +k
        if(double <= addk) {
            result = result * 2;
        } else {
            result = result + k;
        }
    }
    console.log(result);
    
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
   static void Main(string[] args)
   {
      var stringbuilder = new StringBuilder();

      int n;
      while ((n = int.Parse(Console.ReadLine())) != 0)
      {
         int[,] matrix = new int[n, n + 1];

         for (int row = 0; row < n; row++)
         {
            string[] datas = Console.ReadLine().Split(' ');

            int sum = 0;
            for (int column = 0; column < n; column++)
            {
               int val = int.Parse(datas[column]);
               matrix[row, column] = val;
               sum += val;

               stringbuilder.AppendFormat("{0,5}", val);
            }
            matrix[row, n] = sum;

            stringbuilder.AppendFormat("{0,5}\n", sum.ToString());
         }

         for (int column = 0; column <= n; column++)
         {
            int sum = 0;
            for (int row = 0; row < n; row++)
            {
               sum += matrix[row, column];
            }

            stringbuilder.AppendFormat("{0,5}", sum.ToString());
         }
         stringbuilder.AppendLine();
      }

      Console.Write(stringbuilder.ToString());
   }
}

Measured memory_bytes: 9328
///
// File:  alds1_12_a.cpp
// Author: ymiyamoto
//
// Created on Wed Oct 18 01:40:49 2017
//

#include <cstdint>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

#define SIZE 100
struct route_t {
  int64_t weight;
  uint32_t index;

  bool operator<(const route_t w) const
  {
    return weight > w.weight;
  }
};

static int32_t graph[SIZE][SIZE];
static bool visited[SIZE];
static priority_queue<route_t> q;

static uint64_t prim(uint32_t n)
{
  uint64_t total = 0;
  q.push({0, 0});
  while (!q.empty()) {
    route_t r = q.top();
    q.pop();

    if (!visited[r.index]) {
      total += r.weight;
      for (uint32_t i = 0; i < n; i++) {
        if (graph[r.index][i] != -1) {
          q.push({graph[r.index][i], i});
        }
      }
      visited[r.index] = true;
    }
  }
  return total;
}

int32_t main()
{
  uint32_t n;
  cin >> n;
  for (uint32_t i = 0; i < n; i++) {
    for (uint32_t j = 0; j < n; j++) {
      cin >> graph[i][j];
    }
  }

  cout << prim(n) << endl;

  return 0;
}

Measured memory_bytes: 3300
#include<bits/stdc++.h>
using namespace std;
int main(){
  int p;
  cin >> p;
  char s[55];
  cin >> s;
  int t=0;
  for(int i=0;i<p;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      t++;
    }
  }
  cout << t;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	p := scanInt()

	es := make([]edge, m)
	g1 := make([][]int, n)
	g2 := make([][]int, n)
	for i := 0; i < m; i++ {
		a := scanInt() - 1
		b := scanInt() - 1
		c := -scanInt() + p
		es[i] = edge{a, b, c}
		g1[a] = append(g1[a], b)
		g2[b] = append(g2[b], a)
	}

	done := make([]bool, n)

	var dfs func(g [][]int, from int)
	dfs = func(g [][]int, from int) {
		done[from] = true
		for _, to := range g[from] {
			if done[to] {
				continue
			}

			dfs(g, to)
		}
	}

	nes := []edge{}
	dfs(g1, 0)
	for _, e := range es {
		if done[e.from] && done[e.to] {
			nes = append(nes, e)
		}
	}
	es = nes
	nes = []edge{}

	done = make([]bool, n)
	dfs(g2, n-1)
	for _, e := range es {
		if done[e.to] && done[e.from] {
			nes = append(nes, e)
		}
	}

	dist := BellmanFord(nes, n, 0)
	if len(dist) == 0 {
		fmt.Fprintln(wr, -1)
		return
	}

	fmt.Fprintln(wr, max(0, -dist[n-1]))
	// debug(dist)
}

type edge struct {
	from, to, co int
}

// BellmanFord function
func BellmanFord(es []edge, n, st int) []int {
	inf := 1<<31 - 1
	dist := make([]int, n)
	for i := 0; i < n-1; i++ {
		dist[i] = inf
	}
	dist[st] = 0
	chmin := func(a *int, b int) {
		if *a > b {
			*a = b
		}
	}
	for i := 0; i < n-1; i++ {
		for _, e := range es {
			if dist[e.from] == inf {
				continue
			}
			chmin(&dist[e.to], dist[e.from]+e.co)
		}
	}
	for _, e := range es {
		if dist[e.from]+e.co < dist[e.to] {
			return []int{}
		}
	}
	return dist
}


Measured memory_bytes: 2304
package main 
import ("fmt")

func main(){

  var A,B int = 0,0;
  var a string;
  
  fmt.Scanf("%s", &a);

      
  for _, c:= range a{
    if c == 'A'{
      A =1;
    
    }
    if c== 'B'{
    B = 1;
      
    }
  }
  
  if A!=0 && B !=0{
    fmt.Println("Yes");
  }else{
     fmt.Println("No");
  }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<int> a(n+1);
    rep(i,n) cin >> a[i+1];
    const int INF = INT_MAX;
    vector<int> cnt(n+1,INF);
    int now = 1;
    cnt[1] = 0;
    ll j = 0;
    while(j < k) {
        j++;
        now = a[now];
        if(cnt[now] != INF) {
            j += (j-cnt[now])*((k-j)/(j-cnt[now]));
        } else {
            cnt[now] = j;
        }
    }
    cout << now << endl;
}

Measured memory_bytes: 4848
#include<iostream>
#include<iomanip>
#include<algorithm>

using namespace std;

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

int main(){
    int K,S;
    cin >> K >> S;
    int cnt=0;
    REP(i,K+1){
        FOR(j,i,K+1){
            FOR(k,j,K+1){
                if(i+j+k==S){
                    if(i==j&&j==k){
                        cnt += 1;
                    }else if(i==j||j==k){
                        cnt += 3;
                    }else{
                        cnt += 6;
                    }
                }
            }
        }
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin>>s;
	if(s=="SUN")cout<<7;
	if(s== "MON")cout<<6;
	if(s== "TUE")cout<<5;
	if(s== "WED")cout<<4;
	if(s== "THU")cout<<3;
	if(s== "FRI")cout<<2;
	if(s== "SAT")cout<<1;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
#M = int(input())
#S = input()
#a, b = map(int, input().split())
A = list(map(int, input().split()))
#a = list(map(str, input().split()))

#data = []
#for i in range(N):
#    data.append(list(map(int, input().split())))
#print(data)

cnt = 0
i = 1
while True:
    if i >= N:
        break
    if A[i] == A[i-1]:
        cnt += 1
        i += 1
    i += 1

print(cnt)

Measured memory_bytes: 3060
n,k=map(int,input().split())
x=list(map(int,input().split()))
time=100000000000
for i in range(n-k+1):
  l=x[i]
  r=x[i+k-1]
  time=min(time,abs(l)+r-l,abs(r)+r-l)
print(time)
  
      
  


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main(){
	int A, B;
	cin >> A >> B;
	int sum = 0;
	for(int i = 0; i < 2; i++){
		if(A > B){
			sum += A;
			A--;
		}else{
			sum+=B;
			B--;
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != "0 0")
			{
				var WH = s.Split(' ').Select(i => int.Parse(i)).ToArray();
				var tile = new char[WH[0]][];
				for (int i = 0; i < WH[0]; i++)
					tile[i] = Console.ReadLine().ToArray();
				int x = 0, y = 0;
				var loop = false;
				while (tile[y][x] != '.')
				{
					if (tile[y][x] == '#')
					{
						loop = true;
						break;
					}
					else if (tile[y][x] == '<') tile[y][x--] = '#';
					else if (tile[y][x] == '>') tile[y][x++] = '#';
					else if (tile[y][x] == '^') tile[y--][x] = '#';
					else if (tile[y][x] == 'v') tile[y++][x] = '#';
				}
				Console.WriteLine(loop ? "LOOP" : "{0} {1}", x, y);
			}
		}
	}
}

Measured memory_bytes: 12296
#include <bits/stdc++.h>
#include <iostream>
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
 
int main(){
    int n,m,ans=-1;
    bool wrong=true;
   
    cin>>n>>m;
     vector<int>s(m),c(m);
    rep(i,m)cin>>s.at(i)>>c.at(i);
    
    if(n==1){
        for(int i=0;i<10;i++){
            wrong=true;
            rep(j,m){
               //cin>>s>>c;
                if(i!=c.at(j))wrong=false;
            }
             if(wrong){
                cout<<i<<endl;
                ans=i;
                break;
            }
        }
    }
    if(n==2){
        for(int i=10;i<100;i++){
            wrong=true;
            rep(j,m){
                //cin>>s>>c;
                if(s.at(j)==2){
                if(i%10!=c.at(j))wrong=false;
                }
                if(s.at(j)==1){
                if(i/10!=c.at(j))wrong=false;
                }
            }
             if(wrong){
                cout<<i<<endl;
                ans=i;
                break;
            }
        }
    }
    if(n==3){
        for(int i=100;i<1000;i++){
            //ans=i;
            wrong=true;
            
            rep(j,m){
               // cout<<j<<endl;
                //cin>>s>>c;
                if(s.at(j)==3){
                    if(i%10!=c.at(j))wrong=false;
                }
                if(s.at(j)==2){
                    if((i/10)%10!=c.at(j))wrong=false;
                }
                if(s.at(j)==1){
                    if((i/100)!=c.at(j))wrong=false;
                }
            }
            
            if(wrong){
                cout<<i<<endl;
                ans=i;
                break;
            }
        }
    }
    if(ans==-1)cout<<ans<<endl;
}
  



Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
count = 0
index = [0,0]
k = 0

for i in range(N):
    if p[i] != i+1 :
        count = count + 1
        index[k] = i
        k = 1

if count == 0:
    print('YES')
elif count == 2:
    if (p[index[0]] == index[1] + 1) & (p[index[1]] == index[0] + 1):
        print('YES')
    else:
        print('NO')
else:
    print('NO')

Measured memory_bytes: 3064
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,curr,m;
    int tc;
    ll a, b;
    a = 360;
    cin >> b;
    ll gcd = __gcd(a,b);
    ll lcm = a*b / gcd;
    cout << lcm / b << endl;
    return 0;
}


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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  string s;
  cin >>s;
  if(s[0]==s[2]) cout << "Yes" << endl;  
  else cout << "No" << endl;  
  
}



Measured memory_bytes: 3624
#!/usr/bin/env python3
# -*- coding utf-8 -*-

n = int(input())
s = input()

if len(s)%2 == 1:
    print("No")
    exit()

s1 = s[0:len(s)//2]
s2 = s[len(s)//2:len(s)]

if s1 == s2 :
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main()
{
	int n;
	
	while (cin >> n, n){
		int count = 0;
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
			}
			else {
				n = n * 3 + 1;
			}
			count++;
		}
		cout << count << endl;
	}
	return (0);
}

Measured memory_bytes: 1160
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vl w(n);
        rep(i, n) cin >> w[i];
        
        ll now = 0;
        ll ans = ll_inf;
        rep(i, n - 1) {
            now += w[i];
            ll other = 0;
            for (ll j = i + 1; j < n; ++j) {
                other += w[j];
            }
            ans = min(ans, abs(now - other));
        }
        cout << ans << endl;
        

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<ll,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e6 + 5;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    string s;cin >> s;
    if(*max_element(s.begin(),s.end()) != *min_element(s.begin(),s.end()))cout << "Yes";
    else cout << "No";
}



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


using namespace std;

#ifdef CLION
ifstream ifs("/home/kyuridenamida/CLionProjects/project/input.txt");
#define cin ifs
#define scanf DONT_USE_SCANF
#endif

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) cout << "x";
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;


signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  int A[N];
  rep(i, N) cin >> A[i];
  int res = 1;
  int ans = N;
  for(int i=0;i<N;i++){
    if(A[i] == res){
      ans--;
      res++;
    }
  }
  if (ans != N) cout << ans << endl;
  else cout << -1 << endl;
}

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

// -------------------------------
// 関数定義

// 各桁の和を計算する。
int CalcSumOfDigit(int n);


// -------------------------------

int main() {
  int n ;
  vector<int> a;
  
  cin >> n;
  
  for(int i =0;i < n;i++)
  {
    int x = 0;
    cin >> x;
    a.emplace_back(x);
  }

  sort(a.begin(),a.end(),std::greater<int>());

  int sum = 0;
  int j = 0;
  for(int i = 0;i<n;i++)
  {
    if((i+1)%2)
    {
      sum += a[i]; 
    }
    else
    {
      sum -= a[i];
    }
    
  }

cout << sum;
  return 0;
}



// ********************************************************************************************
// ********************************************************************************************
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#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++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    int a;
    vector<int> o(n);
    rep(i,n) {
        cin >> a;
        o[a-1] = i+1;
    }
    rep(i,n) {
        if (i == 0) cout << o[i];
        else cout << " " << o[i]; 
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1664
import numpy as np
li= list(map(int,input().split()))
li_s= list(map(np.sign,li))

if li_s[0]==li_s[1] and li_s[2]==li_s[3] and li_s[0]*li_s[2]==-1:
    print(max(li[0]*li[3],li[1]*li[2]))
else:
    print(max(li[0]*li[2],li[1]*li[3]))

Measured memory_bytes: 26912