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

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define int long long
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t,dp[1005][1005];
int cev;
string s;
char c[1005][1005];
vector<int> v;

inline int add(int x,int y){
	if(x+y>=mod)return x+y-mod;
	return x+y;
}

main(void){
	scanf("%lld %lld",&n,&m);
	FOR{
		for(int j=1;j<=m;j++){
			scanf(" %c",&c[i][j]);
		}
	}
	dp[1][1]=1;
	FOR{
		for(int j=1;j<=m;j++){
			if(c[i][j]=='#')continue;
			else{
				dp[i][j+1]=add(dp[i][j+1],dp[i][j]);
				dp[i+1][j]=add(dp[i+1][j],dp[i][j]);
			}
		}
	}
	printf("%lld\n",dp[n][m]);
	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, K;
	cin >> n >> K;
	vector<long long> x(n), y(n);
	vector<pair<long long, long long>> p(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		p[i].first = x[i];
		p[i].second = y[i];
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	long long ans = numeric_limits<long long>::max();
	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			for(int k = 0; k < n; k++) {
				for(int l = k + 1; l < n; l++) {
					long long left = x[i], right = x[j];
					long long bottom = y[k], top = y[l];
					int cnt = 0;
					for(int m = 0; m < n; m++) {
						if(left <= p[m].first &&  p[m].first <= right && top >= p[m].second && p[m].second >= bottom) {
							cnt++;
						}
					}
					if(cnt >= K) {
						long long area = (long long)abs(right - left) * (long long)abs(top - bottom);
						ans = min(area, ans);
					}
				}
			}
		}
	}
	cout << ans << endl;
	
	return 0;	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
int main(int argc, char const *argv[])
{
    int N, X, T;
    scanf("%i", &N);
    scanf("%i", &X);
    scanf("%i", &T);
    printf("%i\n", (N + X - 1) / X * T);
    return 0;
}


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

int main(){
    int h,w;
    char c[60][60],temp;
    int num[60][60]={};
    cin>>h>>w;

    for(int a=1;a<=h;a++){
        for(int b=1;b<=w;b++){
            cin>>c[a][b];
            if(c[a][b]=='#'){
                for(int i=-1;i<=1;i++){
                    for(int j=-1;j<=1;j++){
                            num[a+i][b+j]++;
                    }
                }
            }
        }
    }

    for(int a=1;a<=h;a++){
        for(int b=1;b<=w;b++){
            if(c[a][b]=='#'){
                cout<<"#";
            }else{
                cout<<num[a][b];
            }
        }
        cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	A := ScanInt(scanner)
	B := ScanInt(scanner)
	K := ScanInt(scanner)
	
	if B - A + 1 >= 2 * K {
    	for i := A; i < A + K; i++ {
    	    fmt.Println(i)
    	}
    	for i := B - K + 1; i <= B; i++ {
    	    fmt.Println(i)
    	}
    } else {
        for i := A; i <= B; i++ {
            fmt.Println(i)
        }
    }
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}
 
ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}
 
ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}
 
ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}
int sz;
vector<ll int>seg;
ll int query(int l,int r)
{
	l+=sz-1;
	r+=sz-1;
	ll int ans=0;
	while(l<r && l>=0)
	{
		if((l&1)==0)
		{
			ans=mx(ans,seg[l]);
			l++;
		}
		if(r&1)
		{
			ans=mx(ans,seg[r]);
			r--;
		}
		l=(l-1)/2;
		r=(r-1)/2;
	}
	if(l==r && l>=0)
	{
		ans=mx(ans,seg[l]);		
	}
	return ans;

}
void upd(int indx,ll int val)
{
	int p=sz-1+indx;
	seg[p]=val;
	while(p>0)
	{
		int tmp=(p-1)/2;
		seg[tmp]=mx(seg[2*tmp+1],seg[2*tmp+2]);
		p=tmp;
	}
	seg[p]=mx(seg[2*p+1],seg[2*p+2]);
	return;
}

int main()
{
	fio
	int n;
	cin>>n;
	sz=pow(2,ceil(log2(n)));
	seg.clear();
	seg.resize(2*sz,0);
	vector<pair<int,int>>h(n);
	vector<ll int>pr(n);
	for(int i=0;i<n;++i)
	{
		cin>>h[i].first;
		h[i].second=i;
	}
	for(int i=0;i<n;++i)
	{
		cin>>pr[i];
	}
	sort(h.begin(),h.end());
	ll int ans=0;
	for(int i=0;i<n;++i)
	{
		pair<int,int>p=h[i];
		ll int tmp=query(0,p.second)+pr[p.second];
		ans=mx(ans,tmp);
		upd(p.second,tmp);
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 10916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

    int T;
    // cin >> T;
    T = 1;

    while (T--) {
        solve();
    }
}

void solve() {
  string s[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
  string t;
  cin >> t;
  rep(i, 8) {
    if (s[i] == t) {
      rep3(j, i + 1, 8) {
        if (s[j] == "SUN") {
          cout << j - i << endl;
          return;
        }
      }
    }
  }
}


Measured memory_bytes: 256
object Main {

  import java.util.Scanner

  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val writer = new java.io.PrintWriter(System.out)
    writer.println(solve(sc))
    writer.flush()
  }

  def solve(sc: Scanner): String = {
    val (n, m) = (sc.nextInt(), sc.nextInt())
    val cards = Array.fill(n)(sc.nextLong()).sorted
    debug(n, m, cards.toSeq)

    IndexedSeq.fill(m)((sc.nextInt(), sc.nextLong())).sortBy(_._2).reverse.foldLeft(0) { case (acc, (b, c)) =>
      var replaced = false
      var i = acc
      while (i < b + acc && i < cards.length && cards(i) < c) {
        cards(i) = c
        replaced = true
        i += 1
      }
      i
    }
    cards.sum.toString
  }

  private def debug(x: Any): Unit = {
    if (System.getenv("LOCAL_DEBUG") != null) println(x)
  }
}


Measured memory_bytes: 117688
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

using LL = long long;

void load(const LL n, const LL d, vector<vector<LL>>& xs)
{
  for (LL i = 0; i < n; ++i) {
    vector<LL> x;
    for (LL j = 0; j < d; ++j) {
      LL c;
      cin >> c;
      x.push_back(c);
    }
    xs.emplace_back(move(x));
  }
}

LL dist2(const vector<LL>& x, const vector<LL>& y)
{
  const auto d = x.size();
  LL sum{0};
  for (auto i = 0u; i < d; ++i) {
    const auto diff = x[i] - y[i];
    sum += diff * diff;
  }
  return sum;
}

bool isSquare(const LL sum)
{
  const LL s = static_cast<LL>(sqrt(static_cast<double>(sum)));
  return s * s - sum == 0;
}

LL count(const LL n, const vector<vector<LL>>& xs)
{
  LL c = 0;
  for (LL i = 0; i < n; ++i) {
    for (LL j = i + 1; j < n; ++j) {
      if (isSquare(dist2(xs[i], xs[j])))
        ++c;
    }
  }
  return c;
}

int main()
{
  LL n;
  LL d;
  cin >> n >> d;
  vector<vector<LL>> xs;
  load(n, d, xs);
  cout << count(n, xs);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	char s[23];
	int a,b;
	scanf("%d%d%s",&a,&b,s);
	if(strchr(s,'-'))
	if(strchr(strchr(s,'-')+1,'-')==NULL){
		int l=strlen(s);
		int A=0;
		for(int i=0;i<l;i++)
			if(s[i]=='-')break;
			else A++;	
		if(A==a&&l==1+A+b){
			printf("Yes\n");
			return 0;	
			}
		}
	printf("No\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    rep(i, n) rep(j, n) cin >> a[i][j];
    vector<vector<int>> b = a;
    rep(k, n) rep(i, n) rep(j, n) b[i][j] = min(b[i][j], b[i][k] + b[k][j]);
    rep(i, n) rep(j, n) if (a[i][j] != b[i][j])
    {
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    rep(i, n) rep(j, n) ans += a[i][j];
    rep(i, n) rep(j, n)
    {
        bool ok = false;
        rep(k, n) if (b[i][j] == b[i][k] + b[k][j] && k != i && k != j) ok = true;
        if (ok)
            ans -= a[i][j];
    }
    cout << ans / 2 << endl;
}

Measured memory_bytes: 1664
#!/bin/env python

def main():
    N, M = map(int, raw_input().split(" "))
    answer = [0] * M
    pref = {}
    for i in xrange(M):
        P, Y = map(int, raw_input().split(" "))
        if P not in pref:
            pref[P] = []
        pref[P].append((i, Y))
    for p, arr in pref.items():
        arr.sort(lambda a, b: a[1] - b[1])
        for i in xrange(1, len(arr)+1):
            item = arr[i-1]
            answer[item[0]]  = ("0" * 5 + str(p))[-6:]
            answer[item[0]] += ("0" * 5 + str(i))[-6:]
    for i in xrange(M):
        print answer[i]

if __name__ == '__main__':
    main()

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

using namespace std;
using namespace __gnu_pbds;

template<class T> using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class T> using ordered_multiset = tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

typedef long long  ll;
typedef unsigned long long  ull;
#define lp(i,n)      for(int i=0;i<n;i++)
#define lpi(i,j,n)   for(int i=j;i<n;i++)
#define lpd(i,j,n)   for(int i=j;i>=n;i--)
#define MP           make_pair
#define clr(v, d)    (memset(v, d, sizeof(v)))
#define all(v)     (v.begin()),(v.end())
#define N 100005
const double pi = acos(-1);

ll n,t,m,k;

ll ans;
ll mod = 1e9 +7;


int main() {
 
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
// freopen("e.txt","r",stdin); 
// freopen("e_out.txt","w",stdout); 
cout.precision(7);

cin>>n;
vector<ll>a(n+1),b(n);
lp(i,n+1)cin>>a[i];
lp(i,n)cin>>b[i];
lp(i,n){
  ll x = min(a[i],b[i]);
  ans+=x;
  b[i]-=x;
  x = min(b[i],a[i+1]);
  ans+=x;
  a[i+1]-=x;
}
cout<<ans;



  
}
  
 



// bool isPrime(ll h){
//      for(ll i=0;primes[i]*primes[i]<= h;i++)
//      if (h%primes[i]==0)
//      	return 0;
//      return h!=1;
//  }
 bool isPrime(ll g){
   if((g%2==0 && g>2) || g==1)return 0;
   for(ll i=3;i*i<=g;i+=2)if(g%i==0)return 0;
   return 1;   
 
 }

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

using namespace std;

int main(){
    int N, M, X, Y;
    array<int, 100> x, y;
    cin >> N >> M >> X >> Y;
    for (int i = 0; i < N; ++i) {
        cin >> x[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> y[i];
    }

    sort(&x[0], &x[N]);
    sort(&y[0], &y[M]);

    if(x[N-1] < y[0] && x[N-1] < Y && X < y[0]){
        cout << "No War" << endl;
    } else{
        cout << "War" << endl;
    }

    return 0;
}


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


int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
    	
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.size();i++)
    {
    	sum+=(s[i]-'0');
    	sum%=9;
    }
    if(sum%9==0)
    	cout<<"Yes"<<endl;
    else
    	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    int N; cin >> N;
    //if(N % 3 != 0){cout << "No" << endl; return 0;}
    map<int, int> M; 
    for(int i = 0; i < N; i++) { int x; cin >> x; M[x]++;}
    set<int> ST; for(auto m : M) ST.insert(m.first);
    if(M.size() > 3){ cout << "No" << endl; return 0;}
    else if(M.size() == 2){
        bool flag = true;
        for(auto st : ST){
            if(st == 0 && M[st] == (N/3)) continue;
            else if(st != 0 && M[st] == 2*(N/3))continue;
            else flag = false;
        }
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else if(M.size() == 1){
        if(M[0] == N) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else {
        bool flag = true;
        for(auto m : M) if(m.second != N/3) flag = false;
        vector<ll> V; for(auto m : M) V.push_back(m.first);
        if((V[0]^V[1]) == V[2] && (V[1]^V[2]) == V[0] && (V[2]^V[0]) == V[1]) ;
        else flag = false;
        if(flag) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


}

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

bool check(char a){
    return a=='A'||a=='C'||a=='G'||a=='T';
}
int main(){
	string a;
	cin>>a;
	int len=a.length();
	int sum=0,tmp=0;
	for(int i=0;i<len;i++){
        if(check(a[i])){
            tmp++;
        }
        else {
           sum=max(sum,tmp);
           tmp=0;
        }
	}
	sum=max(sum,tmp);
	cout<<sum;


}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        String S = scanner.next();
        String T = scanner.next();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < N; i++) {
            sb.append(S.charAt(i));
            sb.append(T.charAt(i));
        }
        System.out.println(sb.toString());
    }

}


Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	getline(cin,s);
	int flag=0;
	for(int i=0;i<s.size();i++)
		if(s[i]=='C')
			for(int j=i+1;j<s.size();j++)
				if(s[j]=='F')
					flag=1;
	if(flag==1)
	{
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
def main():
    A, B, C = list(map(int, input().split()))
    K = int(input())
    k = 0
    while B <= A:
        k += 1
        B *= 2
    while C <= B:
        k += 1
        C *= 2
    return k <= K

print('Yes' if main() else 'No')


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

int main() {
  int N;
  cin >> N;
  
  int a;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    cin >> a;
	A.push_back(a);
  }
  sort(A.begin(), A.end(), greater<int>());
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      sum += A[i];
    } else {
      sum -= A[i];
    }
    //cerr << A[i] << ' ' << sum << endl;
  }
  
  cout << sum << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	string s,t;
	cin>>s;
	cin>>t;
	ll i,j,k,l,n=s.length(),m=t.length();
	ll f1[26]={0},f2[26]={0};
	for(i=0;i<n;i++){
		f1[s[i]-'a']++;
	}
	for(i=0;i<m;i++){
		f2[t[i]-'a']++;
	}

	ll flg=1;
	for(i=0;i<26;i++){
		if(f2[i]>0&&f1[i]==0){
			flg=0;
			break;
		}
		f1[i]=1e10;
	}
	if(!flg){
		cout<<"-1";return 0;
	}

	vector<ll> vc[26];
	for(i=0;i<n;i++){
		vc[s[i]-'a'].ps(i);
	}
//	cout<<vc['o'-'a'][0]<<endl;

	ll rep=0,idx=0,las=-1;
	for(i=0;i<m;i++){
		k=upper_bound(all(vc[t[i]-'a']),las)-vc[t[i]-'a'].begin();
		if(k==vc[t[i]-'a'].size()){
			k=0; rep++;
		}
		idx=vc[t[i]-'a'][k];
		las=vc[t[i]-'a'][k];
	}
	if(ceil(log(rep))>100){
		cout<<"-1";return 0;
	}
	cout<<(rep*n+idx+1);
	return 0;
}

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define T top()
#define E end()
#define PS push
#define Q queue
#define PP pop()
#define L0 (LL)0
#define V vector
#define ST stack
#define FI first
#define MAX 4e18
#define MIN -MAX
#define DQ deque
#define RE rend()
#define SZ size()
#define C clear()
#define B begin()
#define F front()
#define SE second
#define DL double
#define G getline
#define IN insert
#define endl "\n"
#define EM empty()
#define EE emplace
#define RB rbegin()
#define MD 1000000007
#define PSB push_back
#define PI acos(-1.00)
#define PPB pop_back()
#define PSF push_front
#define ub upper_bound
#define lb lower_bound
#define PPF pop_front()
#define EB emplace_back
#define LL long long int
#define PQ priority_queue
#define N cout<<"No"<<endl
#define Y cout<<"Yes"<<endl
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
#define UOSMOY v.C;w.C;ww.C;u.C;uu.C;uo.C;vo.C;vu.C;ab.C;bc.C;cc.C;uuu.C;a.C;b.C;c.C
V<LL>v;
V<LL>w,ab,bc;
set<LL>uo;
map<LL,LL>u;
map<LL,LL>ww,cc;
V<pair<LL,LL> >uu;
map<LL,V<LL> >uuu;
map<pair<LL,LL>,LL> vo;
map<pair<LL,LL>,LL> vu;
LL ar[100];
LL dxx[]= {-1,0,1,0};
LL dyy[]= {0,1,0,-1};
LL dx[]= {2,1,-1,-2,-2,-1,1,2};
LL dy[]= {1,2,2,1,-1,-2,-2,-1};
int main()
{
//  BRR;
//  file;
    FAST;
    char ch;
    string a,b,c;
    DL x,y,d,e,f,g,h;
    LL n,m,i,j,k,p,q,o,l,s,tt=1,t,z,aa,r=0;
//    cin>>tt;
    while(tt--)
    {
        UOSMOY;
        cin>>n>>m;
        y=1.00;
        for(i=0; i<n; i++)
        {
            cin>>o;
            u[i]=o;
        }
        for(i=m;i<n;i++)
        {
            d=u[i-m];
            e=u[i];
            if(d>=e)
            {
                N;
            }
            else
            {
                Y;
            }
        }
    }
    return 0;
    //IN
    //AL
}


Measured memory_bytes: 16160
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005

int n,a[105],k;

ll mod=1e9+7,dp[105][100005],s[105][100005];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> k;
    dp[0][0]=1;
    for(int i=0;i<=k;i++) s[0][i]=1;
    for(int i=1;i<=n;i++){
        cin >> a[i];
        for(int j=0;j<=k;j++){
            if(j-a[i]-1>=0) dp[i][j]=(s[i-1][j]-s[i-1][j-a[i]-1]+mod)%mod;
            else dp[i][j]=s[i-1][j];
            if(j) s[i][j]=(s[i][j-1]+dp[i][j])%mod;
            else s[i][j]=dp[i][j];
        }
    }
    cout << dp[n][k];
}


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

using namespace std;

int inf = (int)1e9 + 5;

int main() {
    int N, K;

    scanf("%d %d", &N, &K);
    vector<int> hs(N), dp(N, inf);

    for (int& e: hs)
        scanf("%d", &e);

    dp[0] = 0;
    for (int i = 0; i < N; i++)
        for (int j = 1; j <= K; j++)
            if (i + j < N)
                dp[i + j] = min(dp[i + j], dp[i] + abs(hs[i] - hs[i + j]));

    printf("%d\n", dp[N - 1]);

    return 0;
}

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

#define loop(i, n) for(int i = 0; i < n; i++)
#define sloop(i, s, n) for (int i = s; i < n; i++)
#define rloop(i, n) for (int i = n - 1; i >= 0; i--)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    long long int count = 0, ans = 0;
    rloop(i, s.size()) {
        if(s[i] == 'W') count++;
        else ans += count;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3784
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        long ans = 0;
        int prev = A[0];
        for (int i = 1; i < N; i++) {
            if (prev <= A[i]) {
                prev = A[i];
            } else {
                ans += prev-A[i];
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 61120
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define DREP(i,n,N) for(int i=n;i>=N;i--)
#define print(S) cout<<S<<endl;
using namespace std;
 
int main() {
	int N;
	cin>>N;
	if(N<1200) {
		print("ABC");
	}else {
		print("ARC");
	}
	return 0;
}

Measured memory_bytes: 384
#include <sstream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cassert>
#include <ctime>
#include <map>
#include <math.h>
#include <cstdio>
#include <set>
#include <deque>
#include <memory.h>
#include <queue>

#pragma comment(linker, "/STACK:64000000")
typedef long long ll;

using namespace std;

const int MAXN = 1 << 18;
const int MOD = 1; // 1000 * 1000 * 1000 + 7;
const int INF = 2e9;
const double PI = acos(-1.0);

void print(vector<int> a) {
	if (a.empty()) cout << "No" << endl;
	else {
		cout << "Yes" << endl;
		for (int i = 0; i < (int)a.size(); i++) cout << a[i] + 1 << " \n"[i + 1 == (int)a.size()];
	}
}

vector<int> solve(vector<int> x) {
	int n = x.size();
	vector<pair<int, int> > a(n);
	for (int i = 0; i < n; i++) {
		a[i] = make_pair(x[i], i);
	}
	sort(a.begin(), a.end());

	vector<int> ans;
	vector<int> canUse;
	vector<int> cnt(n, 0);
	int j = 0, k = 0;
	for (int i = 0; i < n * n; i++) {
		if (k < n && a[k].second == 0) k++;
		if (j < n && i == a[j].first) {
			int x = a[j].second;
			if (cnt[x] != x) return vector<int>();
			ans.push_back(x);
			for (int l = x + 1; l < n; l++) canUse.push_back(x);
			j++;
			continue;
		}
		if (k < n) {
			int x = a[k].second;
			ans.push_back(x);
			cnt[x]++;
			if (cnt[x] == x) {
				k++;
			}
			continue;
		}
		if (!canUse.empty()) {
			int x = canUse.back();
			canUse.pop_back();
			ans.push_back(x);
			continue;
		}
		return vector<int>();
	}
	return ans;
}

int main() {
#ifdef _MSC_VER
	freopen("input.txt", "r", stdin);
#endif

	int n;
	while (cin >> n) {
		vector<int> x(n);
		for (int i = 0; i < n; i++) {
			cin >> x[i];
			x[i]--;
		}
		print(solve(x));
	}

	return 0;
}

Measured memory_bytes: 2456
from collections import defaultdict
from itertools import product

_ = input()
N = list(map(int, input()))

cnt = [defaultdict(int) for _ in range(len(N) + 1)]
left = [10 ** 10] * 10
right = [-1] * 10

for i, n in enumerate(N):
    left[n] = min(left[n], i)
    right[n] = max(right[n], i)

    for j in range(10):
        cnt[i + 1][j] = cnt[i][j]
    cnt[i + 1][n] += 1

ans = 0
for l, m, r in product(range(10), repeat=3):
    l = left[l]
    r = right[r]

    if l < r and cnt[r][m] - cnt[l + 1][m] > 0:
        ans += 1

print(ans)

Measured memory_bytes: 19496
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    cin>>x>>y;
    bool ok = false;
    for(int i=0;i<=x;i++){
        if(i*2+(x-i)*4==y){
            ok = true;
        }
    }
    if(ok){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }


    return 0;
}

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

int main() {
long long a,b,x;
cin>>a>>b>>x;
a--;
if(a>0){
a=(a-a%x)/x;
}
if(b>0){
b=(b-b%x)/x;
}
cout<<b-a<<endl;

	return 0;
}

Measured memory_bytes: 256
def simu(i, j, c):
    if A[i] >= B[j]:
        q = B[j]
        A[i] -= B[j]
        B[j] = 0
    else:
        q = A[i]
        B[j] -= A[i]
        A[i] = 0
        if not c:
            q += simu(i + 1, j, True)
    return q


N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

p = 0
for i in range(N):
    p += simu(i, i, False)

print(p)

Measured memory_bytes: 18476
package main

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


func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	ans := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		d1, _ := strconv.Atoi(sc.Text())
		sc.Scan()
		d2, _ := strconv.Atoi(sc.Text())

		if d1== d2 {
			ans++
			if ans >= 3 {
				fmt.Println("Yes")
				return
			}
		} else {
			ans = 0
		}
	}

	fmt.Println("No")
}



Measured memory_bytes: 1844
#include <stdio.h>

int main(void){
	int a[2];
	int yard = 0;

	scanf("%d", &a[0]);
	scanf("%d", &a[1]);

	yard = a[0]*a[1]-(a[0]+a[1])+1;

	printf("%d\n", yard);

	return 0;
}


Measured memory_bytes: 128
public class Main {

	private static int ld() {
		try (final java.util.Scanner sc = new java.util.Scanner(System.in)) {
			return sc.nextInt();
		}
	}
	
	public static void main(String[] args) {
		int n = ld();
		int rvalue;
		for (rvalue = 1; ; ++rvalue) {
			if (n <= 3) break ;
			n = (n / 3) + (n % 3 == 0 ? 0 : 1);
		}
		System.out.println(rvalue);
	}

}



Measured memory_bytes: 26152
#include<stdio.h>
int main(void){
 int n=0;
 char s1[1],s2[1],s3[1];
  scanf("%s",&s1[1]);
  scanf("%s",&s2[1]);
  scanf("%s",&s3[1]);
if(s1[1]=='1') n+=1;
if(s2[1]=='1') n+=1;
if(s3[1]=='1') n+=1;
printf("%d",n);
return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	int minAbCost = min(a + b, 2 * c);

	if (x == y) {
		cout << minAbCost * x;
		return 0;
	}

	int ans = minAbCost * min(x, y);
	if (x > y) {
		int add = a < 2*c ? (x - y) * a : (x - y) * 2*c;
		cout << ans + add << endl;
	} else {
		int add = b < 2 * c ? (y - x) * b : (y - x) * 2 * c;
		cout << ans + add << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    long long ans;
    if(A + B < 2 * C) {
        ans = A * X + B * Y;
    } else {
        if(X > Y) {
            ans = Y * 2 * C;
            ans += (A < 2 * C) ? A * (X - Y) : C * 2 * (X - Y);
        } else {
            ans = X * 2 * C;
            ans += (B < 2 * C) ? B * (Y - X) : C * 2 * (Y - X);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    for(int i = 1; i <= 3; i++)
    {
        if(a*b*i%2)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
#define size(v) (signed)v.size()
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

set<int> P[100000];
int vis[100000];
long dc, sc, oc, dg, sg;

bool dfs(int i, int g, bool d = false) {
    if(vis[i]) return false;
    bool ret = false;
    vis[i] = d ? g : -g;
    for(int j: P[i]) {
        if(vis[i] == vis[j]) ret = true;
        if(dfs(j, g, !d)) ret = true;
    }
    return ret;
}

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    int N, M;
    scanf("%d%d", &N, &M);
    // set<int> P[100000];
    times(M, i) {
        int u, v; scanf("%d%d", &u, &v);
        P[u-1].insert(v-1);
        P[v-1].insert(u-1);
    }

    // int vis[100000], dc, sc, oc, dg, sg;
    int cat[100001], g = 0;
    cat[0] = 0;
    times(N, i) {
        if(not vis[i]) {
            if(not P[i].empty()) {
                ++g;
                if(dfs(i, g)) {
                    ++sg;
                    cat[g] = 1;
                } else {
                    ++dg;
                    cat[g] = 2;
                }
            }
        }
        switch(cat[abs(vis[i])]) {
            case 0: ++oc; break;
            case 1: ++sc; break;
            case 2: ++dc; break;
        }
    }

    if(debug) {
        times(N, i) cout << (i?" ":"") << vis[i]; cout ln;
        times(N, i) cout << (i?" ":"") << cat[i]; cout ln;
        cout << "o:" << oc << " s:" << sc sp << sg << " d:" << dc sp << dg ln;
    }

    cout << dg * dg * 2 + dg * sg * 2 + sg * sg + oc * N * 2 - oc * oc ln;

    return 0;
}


Measured memory_bytes: 28800
#include <bits/stdc++.h>
#define rep(i, to) for (int i = 0; i < (to); i++)
#define rrep(i, to) for (int i = (to) - 1; i >= 0; i--)
#define repf(i, from, to) for (int i = (from); i < (to); i++)
#define all(v) v.begin(), v.end()
#define unless(cond) if (!(cond))
using namespace std;
using ll = long long;
template <typename T>
using V = vector<T>;
template <typename T, typename U>
using P = pair<T, U>;

int main() {
  int n;
  V<V<int>> graph;
  cin >> n;
  graph.resize(n);

  rep(i, n) {
    int u, k;
    cin >> u >> k;
    graph[u - 1].resize(k);

    rep(j, k) {
      cin >> graph[u - 1][j];
      graph[u - 1][j]--;
    }
  }

  stack<int> way;

  V<bool> visited(n, false);
  V<int> arrived_t(n, 0);
  V<int> finished_t(n, 0);

  int t = 0;
  rep(i, n) {
    if(visited[i]) {
      continue;
    }
    visited[i] = true;
    arrived_t[i] = ++t;
    way.push(i);

    while(!way.empty()) {
      int current_i = way.top();

      int next_i = -1;
      rep(i, graph[current_i].size()) {
        int tmp_next_i = graph[current_i][i];
        if(!visited[tmp_next_i]) {
          next_i = tmp_next_i;
          break;
        }
      }

      t++;
      if(next_i != -1) {
        visited[next_i] = true;
        arrived_t[next_i] = t;
        way.push(next_i);
      } else {
        way.pop();
        finished_t[current_i] = t;
      }
    }
  }


  rep(i, n) {
    cout << i + 1 << " " << arrived_t[i] << " " << finished_t[i] << endl;;
  }

}



Measured memory_bytes: 3108
/*
  AOJ 1286
  Title:Expected Allowance
  @kankichi573
*/
#include <stdio.h>
#include <math.h>
#include <float.h>

// #define max(x,y) (((x)>(y))?(x):(y))
// #define min(x,y) (((x)<(y))?(x):(y))
double expt(double x,int n)
{
  if(n==0)
    return(1.0);
  else
    return(x*expt(x,n-1));
}

int n_deme(int sum,int dice,int m)
{
  int i,ret;

  if(sum < dice || sum > dice*m)
    return(0);
  if(dice==1)
    return(1);
  for(i=1,ret=0;i<=m;i++)
    ret += n_deme(sum-i,dice-1,m);
  return(ret);
}
double prob(int thre,int dice,int m)
{
  double ret;
  int i;
  for(i=1,ret=0.0;i<=thre;i++)
    ret += (double)n_deme(i,dice,m)/expt(m,dice);
  for(i=thre+1;i<=dice*m;i++)
    ret += (double)n_deme(i,dice,m)*(i-thre)/expt(m,dice);
  return(ret);
}
main()
{
  int n,m,k;
  double ret;

  while(scanf("%d %d %d",&n,&m,&k) && (n||m||k))
    {
      ret=prob(k,n,m);
      printf("%.8lf\n",ret);
    }
  return(0);

}

Measured memory_bytes: 636
#include <iostream>
#include <math.h>
using namespace std;

long long n,a[20000005],maxx;

bool sdown(int i,int j,int k) {
	return a[j]<=k && a[i]<=k;
}

bool sup(int i,int j,int k) {
	return a[j]>k && a[i]>k;
}

bool check(int k) {
	for(int i=0;i<n;i++) {
		if(sup(n+i,n+i+1,k) || sup(n-i,n-i-1,k)) return 0;
		if(sdown(n+i,n+i+1,k) || sdown(n-i,n-i-1,k)) return 1;
	}
	return sdown(1,1,k);
}

int main() {
	scanf("%lld",&n);
	for(int i=1;i<=2*n-1;i++) {
		scanf("%lld",&a[i]);
		//maxx=max(maxx,a[i]);
	}
	long long l=1,r=2*n-1;
	while(l<r) {
		long long mid=(l+r)/2;
		if(check(mid)) {
			r=mid;
		} else {
			l=mid+1;
		}
	}
	printf("%lld\n",r);
	
	return 0;
} 

Measured memory_bytes: 1920
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
	char s[3][3];
	for(int i=0;i<3;i++) for(int j=0;j<3;j++) cin>>s[i][j];
	cout<<s[0][0]<<s[1][1]<<s[2][2]<<endl;
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <string>
#include <locale>
#include <stack>
#include <map>
#include <queue>
#include <list>
using namespace std;

void funcInsert(list<int> & arr ) {
	int a; cin >> a;
	arr.push_front(a);
}
void funcDelete(list<int> & arr ) {
	int a; cin >> a;

	list<int>::iterator it = arr.begin(), itend = arr.end();
	for(;it != itend; advance(it,1))
		if (*it == a) {
			arr.erase(it);
			break;
		}

}
void funcDelFirst(list<int> & arr) {
	arr.pop_front();
}
void funcDelLast(list<int> & arr) {
	arr.pop_back();
}
typedef map<string, void(*)(list<int>&)> map_type;
void listprint(list<int> & arr) {
	list<int>::iterator it = arr.begin(), itend = arr.end();
	cout << *it;
	advance(it, 1);
	for (; it != itend; advance(it, 1))
		cout << " " << *it;
	cout << endl;
}

int main(void)
{

	map_type funcs;
	map_type::iterator it;
	funcs.insert(make_pair("insert", funcInsert));
	funcs.insert(make_pair("delete", funcDelete));
	funcs.insert(make_pair("deleteFirst", funcDelFirst));
	funcs.insert(make_pair("deleteLast", funcDelLast));

	list<int> arr;

	int n;
	string comand;
	cin >> n;
	for (size_t i = 0; i < n; i++)
	{
		cin >> comand;
		it = funcs.find(comand);
		it->second(arr);
	}
	listprint(arr);


	return 0;
}

Measured memory_bytes: 34388
// AOJ Volume 1 Problem 0104

#include <stdio.h>
#include <string.h>

int main(void)
{
	char map[100][101];
	int w, h;
	int x, y;
	int i;
	
	while (1){
		scanf("%d%d", &h, &w);
		if (w == 0 && h == 0){
			break;
		}
		
		for (i = 0; i < h; i++){
			scanf("%s", map[i]);
		}
		
		x = y = 0;
		
		while (1){
			if (map[y][x] == '>'){
				map[y][x] = 'x';
				x++;
			}
			else if (map[y][x] == '<'){
				map[y][x] = 'x';
				x--;
			}
			else if (map[y][x] == '^'){
				map[y][x] = 'x';
				y--;
			}
			else if (map[y][x] == 'v'){
				map[y][x] = 'x';
				y++;
			}
			else if (map[y][x] == '.'){
				printf("%d %d\n", x, y);
				break;
			}
			else {
				printf("LOOP\n");
				break;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
void main()
{
    long a, b, k;
    rdVals(a, b, k);

    foreach (i; 0 .. k)
    {
        if (i & 1)
        {
            b >>= 1;
            a += b;
        }
        else
        {
            a >>= 1;
            b += a;
        }
    }

    writeln(a, " ", b);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

const int mod = 1e9 + 7;
// 経路の数え上げ
// まず左端の列, 右上の行を初期化する
// あとは, 右側+上側で値を更新する　

int main(){
    int h, w;
    cin >> h >> w;
    
    vector<vector<char>> grid(h, vector<char>(w));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) cin >> grid[i][j];
    }
    
    vector<vector<int>> number_of_paths(h+2, vector<int>(w+2, 0));
    
    number_of_paths[0][0] = 1;
    
    for (int i = 1; i < h; i++){
        if (grid[i][0] == '#') break;
        number_of_paths[i][0] = 1;
    }
    
     for (int j = 1; j < w; j++){
        if (grid[0][j] == '#') break;
        number_of_paths[0][j] = 1;
    }
    
    /*for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) cout << number_of_paths[i][j];
        cout << endl;
    }*/
    
    for (int i = 0; i < h-1; i++){
        for (int j = 0; j < w-1; j++){
            
            if (grid[i+1][j+1] == '#') continue;
            number_of_paths[i+1][j+1] = (number_of_paths[i+1][j+1] + number_of_paths[i+1][j] + number_of_paths[i][j+1]) % mod;
        }
    }
    
    cout << number_of_paths[h-1][w-1] << endl;
    
}

Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define MP(x,y) make_pair(x,y)
#define X first
#define Y second
#define all(x) x.begin(), x.end()

using namespace std;
using ll= long long ;

ll result[2][128];
// 0:偶数, 1:奇数

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

  cin >> n;
  a.resize(n);
  rep(i,n){
    cin >> a[i];
  }
  ll y = 0;
  if(a[0]%2){
    y = 1;
  }else{
    y = 2;
  }
  for(int i = 1; i < n; ++i){
    if(a[i]%2){
      y *= 1;
    }else{
      y *= 2;
    }
  }
  
  ll x = 1;
  rep(i,n){
    x *= 3;
  }
  cout << x - y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    int hud, ten, one;
    hud = n / 100;
    ten = (n - hud * 100) / 10;
    one = (n - hud * 100 - ten * 10);
    if (hud == 7 || ten == 7 || one == 7) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<val)val = rest[i];return val}
function max(){var rest = arguments,val=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>val)val = rest[i];return val}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n');
	input = input[0].split(' ');
	var as = toIntArr(input).sort(function(a,b){return a-b});

	console.log(as[2] - as[0]);	
}

Measured memory_bytes: 21192
#include <bits/stdc++.h>
using namespace std;
// a < b < c

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    int k;
    cin >> k;
    string ans = "No";
    for (int i = 0; i < pow(3, k); i++){
        int temp = i;
        int temp_a[3];
        for (int j = 0; j < 3; j++)temp_a[j] = a[j];
        
        while(temp > 0){
            for (int j = 0; j < 3; j++)
            {
                if(temp % 3 == j)temp_a[j] *= 2;
            }
            temp /= 3;
        }
        if(temp_a[0] < temp_a[1] && temp_a[1] < temp_a[2])ans = "Yes";
    }
    cout << ans << endl;  

    return 0;
}

Measured memory_bytes: 4000
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[0] == 0:
    print(0)
else:
    ans = -1
    for i in range(n):
        if(ans == -1):
            ans = a[i]
        else:
            ans *= a[i]
            if(ans > 1e18):
                ans = -1
                break
    print(ans)

Measured memory_bytes: 21652
#include<iostream>
#include<math.h>

using namespace std;

long gcd(long n, long m) {
    if (n < m)swap(n, m);
    if (n == m || m == 0)return n;
    return gcd(m, n % m);
}

long pri(){
    long ans = 0;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        int m;
        bool flag = false;
        cin >> m;
        for(int j = 2; j <= sqrt(m); j++){
            if(m % j == 0) {
                flag = true;
                break;
            }
        }
        if(!flag) ans++;
    }
    return ans;
}

int main() {
    cout << pri() << endl;
}


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

using namespace std;

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

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100050

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2147483647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい]
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}
		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}

	bool same(int x,int y){
		return root(x) == root(y);
	}
};


//
int main(){
	int N,M;cin>>N>>M;
	V A(N),B(N),order(N);
	REP(i,N)cin >> A[i] >> B[i];

	iota(ALL(order),0);
	sort(ALL(order),[&](int x,int y){return A[x] < A[y];});

	ll ans = 0;
	ll suml = 0;
	REP(i,N){
		if(suml + B[order[i]] > M){
			ans += (ll)(M-suml)*A[order[i]];
			break;
		}
		ans += (ll)A[order[i]] * B[order[i]];
		suml += B[order[i]];
	}

	cout << ans << endl;

	return 0;
}




Measured memory_bytes: 1536
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;
typedef pair< int, int > pii;

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

  string s, t;
  cin >> s >> t;

  bool ans = false;
  int n = s.length();
  for(int i = 0; i < n; i++){
    char last = s[n - 1];
    s.pop_back();
    s.insert(0, 1, last);
    if(s == t){
      ans = true;
      break;
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256