akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int go(int &pos, pair<int, int> seg) {
    if (pos < seg.first) {
        int res = seg.first - pos;
        pos = seg.first;
        return res;
    }
    if (pos > seg.second) {
        int res = pos - seg.second;
        pos = seg.second;
        return res;
    }
    return 0;
}

ll solve(vector<pair<int, int> > a) {
    multiset<pair<int, int> > left, right;
    for (auto seg : a) {
        right.insert(seg);
        swap(seg.first, seg.second);
        left.insert(seg);
    }
    ll res = 0;
    int pos = 0;
    int dir = 1;
    for (int i = 0; i < a.size(); i++) {
        if (dir == 1) {
            auto cur = right.end();
            cur--;
            res += go(pos, *cur);
            auto fn = *cur;
            swap(fn.first, fn.second);
            auto tmp = left.find(fn);
            left.erase(tmp);
            right.erase(cur);
        } else {
            auto cur = left.begin();
            auto fn = *cur;
            swap(fn.first, fn.second);
            res += go(pos, fn);
            auto tmp = right.find(fn);
            left.erase(cur);
            right.erase(tmp);
        }
        dir = dir == 1 ? -1 : 1;
    }
    return res + abs(pos);
}

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

    int n;
    cin >> n;
    vector<pair<int, int> > a(n);
    for (int i = 0; i < n; ++i) {
        int l, r;
        cin >> l >> r;
        a[i] = {l, r};
    }
    ll ans = solve(a);
    for (int i = 0; i < n; ++i) {
        a[i].first *= -1;
        a[i].second *= -1;
        swap(a[i].first, a[i].second);
    }
    ans = max(ans, solve(a));
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 11384
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			String s = scan.next();
			if (s.equals("."))
				return;
			String p = scan.next();
			int pHash = eval(s, p);
			int hashSum = 0;
			for (int i = 0; i <= 9999; i++) {
				int num  = i;
				String pass = Integer.toString(num / 1000);
				num -= 1000 * (num / 1000);
				pass += Integer.toString(num / 100);
				num -= 100 * (num / 100);
				pass += Integer.toString(num / 10);
				num -= 10 * (num / 10);
				pass += Integer.toString(num);
				if (pHash == eval(s, pass))
					hashSum++;
			}
			System.out.println(pHash + " " + hashSum);
		}
	}
	
	int eval(String s, String p) {
//		System.out.println(s);
		if (s.length() == 1) {
			switch(s) {
			case "a": return p.charAt(0) - '0';
			case "b": return p.charAt(1) - '0';
			case "c": return p.charAt(2) - '0';
			case "d": return p.charAt(3) - '0';
			default:
				throw new Error("internal error: " + s);
			}
		}
		int index = 1;
		char op = s.charAt(index++);
		int lhv = 0, rhv = 0;
//		System.out.println("left");
		if (s.charAt(index) != '[') {
			lhv = eval(s.substring(index, index + 1), p);
			index++;
		} else {
			int idx = index;
			int kakko = 1;
			while (kakko != 0) {
				idx++;
				if (s.charAt(idx) == '[') kakko++;
				else if (s.charAt(idx) == ']') kakko--;
			}
//			System.out.println("lhv: " + s + " " + index + " " + idx);
//			System.out.println(s.substring(index, idx + 1));
			lhv = eval(s.substring(index, idx + 1), p);
			index = idx + 1;
		}
//		System.out.println("right");
		if (s.charAt(index) != '[') {
			rhv = eval(s.substring(index, index + 1), p);
		} else {
			int idx = index;
			int kakko = 1;
			while (kakko != 0) {
				idx++;
				if (s.charAt(idx) == '[') kakko++;
				else if (s.charAt(idx) == ']') kakko--;
			}
//			System.out.println("rhv: " + s + " " + index + " " + idx);
//			System.out.println(s.substring(index, idx + 1));
			rhv = eval(s.substring(index, idx + 1), p);
		}
		switch(op) {
		case '+': return lhv | rhv;
		case '*': return lhv & rhv;
		case '^': return lhv ^ rhv;
		default:
			throw new Error("internal error");
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 287568
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
 int N,K;
 std::cin>>N>>K;
 std::vector<int> A(N);
 for(int i=0;i<N;i++){
  std::cin>>A[i];
 }
 
 for(int i=0;i<K;i++){
  int flag=1;
  for(int i=0;i<N;i++){
   if(A[i]!=N){
    flag=0;
    break;
   }
  }
  if(flag){
   break;
  }
  std::vector<int> B(N,0);
  for(int i=0;i<N;i++){
   int l=std::max(0,i-A[i]);
   int r=std::min(N-1,i+A[i]);
   B[l]++;
   if(r+1<N) B[r+1]--;
  }
  for(int i=1;i<N;i++) B[i]+=B[i-1];
  A=B;
 }
 for(int i=0;i<N;i++){
  std::cout<<A[i]<<" ";
 }
 std::cout<<std::endl;

 return 0;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>

int f(int n){
  if(n % 2 == 0)
    return n / 2;
  else
    return 3 * n + 1;
}

int main(){
  int s;
  cin >> s;
  
  map<int, int> number_map;
  int count = 1;
  while(true){
    if(number_map[s] == 0)
      number_map[s] = 1;
    else
      break;
    count++;
    s = f(s);
  }
  cout << count << endl;
}

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

int main() {
    int N; cin >> N;
    int f[N+1] = {};
    for (int x = 1; x <= 100; x++) {
        for (int y = 1; y <= 100; y++) {
            for (int z = 1; z <= 100; z++) {
                int n = x*x + y*y + z*z + x*y + y*z + z*x;
                if (n > N) break;
                f[n]++;
            }
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << f[i] << endl;
    }
}

Measured memory_bytes: 3656
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class EGetEverything {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n, m;
    cin >> n >> m;
    vector<int> A(m), B(m), C(m);

    for (int i = 0; i < m; i++){
        cin >> A[i] >> B[i];
        for (int j = 0; j < B[i]; j++){
            int c;
            cin >> c;
            C[i] += 1 << (c - 1);
        }
    }

    const int INF = 1e9;
    vector<int> DP(1 << n, INF);
    DP[0] = 0;

    for (int bits = 0; bits < (1 << n); bits++){
        for (int i = 0; i < m; i++){
            int c = C[i];
            int a = A[i];
            DP[bits | c] = min(DP[bits | c], DP[bits] + a);
        }
    }

    cout << (DP[(1 << n) - 1] == INF ? -1 : DP[(1 << n) - 1]) << endl;
}
};

int main() {
	EGetEverything solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

// BEGIN NO SAD
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// END NO SAD

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

pii l[8];
void solve() {
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> l[i].first >> l[i].second;
  vector<int> v;
  for(int i = 0; i < n; i++) v.push_back(i);
  double sum = 0;
  do {
    for(int i = 0; i < n-1; i++) {
      sum += hypot(l[v[i+1]].second - l[v[i]].second, l[v[i+1]].first - l[v[i]].first);
    }
  }
  while(next_permutation(all(v)));
  for(int i = 2; i <= n; i++) sum /= i;
  cout << fixed << setprecision(12) << sum << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int m, d;
	cin >> m >> d;
	int ans = 0;
	for(int i = 2; i < 10; ++i) {
		for(int j = 2; j < 10; ++j) {
			if(i * 10 + j <= d && i * j <= m) {
				++ans;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
  int h,w;
  cin>>h>>w;
  char pic[w][h];
  rep(i,h)rep(j,w){
    cin>>pic[j][i];
  }
  rep(i,h){
    rep(tmp,2){
      rep(j,w){
        cout<<pic[j][i];
      }
      cout<<endl;
    }
  }
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    h = [int(x) for x in input().split()]

    dp = [-1]*N
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])

    for i in range(2,N):
        dp[i] = min(abs(h[i]-h[j]) + dp[j] for j in range(max(0,i-K),i))
    print(dp[N-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 53472
using System.Text;
using System.Collections.Generic;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var a = new int[n];
        for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
        getAns(a, n, m);
    }
    static void getAns(int[] a, int n, int m)
    {
        Array.Reverse(a);
        var count = 0;
        var hs = new HashSet<int>();
        var sb = new StringBuilder();
        for (int i = 0; i < n; i++)
            if (hs.Add(a[i]))
            {
                sb.Append(string.Format("{0}\n", a[i]));
                count++;
                if (count == m) break;
            }
        Console.Write(sb);
    }
}



Measured memory_bytes: 27112
s=int(input())
t=[]
for i in range(s):
    u,l=map(int,input().split())
    t.append((u-l,u+l-1))
t.sort(key=lambda x: x[1])
d=-10**10
ans=0
for i in range(s):
  if d<t[i][0]:
    ans+=1
    d=t[i][1]
print(ans)

Measured memory_bytes: 18256
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define Ans(s) cout << s << endl;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;


int main()
{
	int n, m;
	cin >> n >> m;
	vector<bool> isSafe(n + 1, true);

	rep(i, m)
	{
		int val;
		cin >> val;
		isSafe[val] = false;
	}

	vector<int> dp(n + 1);
	dp[0] = 1;
	if (isSafe[1]) dp[1] = 1;

	for (int i = 2; i <= n; i++)
	{
		if (isSafe[i - 1]) dp[i] += dp[i - 1];
		if (isSafe[i - 2]) dp[i] += dp[i - 2];
		dp[i] %= mod;
	}
	cout << dp[n] << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline int read(){
    int x(0),w(1); char c = getchar();
    while(c^'-' && (c<'0'||c>'9')) c = getchar();
    if(c == '-') w = -1, c = getchar();
    while(c>='0' && c<='9') x = (x<<3) + (x<<1) + c - '0', c = getchar();
    return x*w;
}
int n,x,y,z,c[100010];
int head[100010],nxt[200010],to[200010],cost[200010],cnt;
inline void add(int u, int v, int w){
	to[++cnt] = v;
	cost[cnt] = w;
	nxt[cnt] = head[u];
	head[u] = cnt;
}
void dfs(int u, int Fa){
	int v;
	if(u == 1) c[u] = 0;
	for(int i = head[u]; i; i = nxt[i]){
		v = to[i];
		if(v == Fa) continue;
		if(cost[i] % 2 == 0) c[v] = c[u];
		else c[v] = c[u]^1;
		dfs(v,u);
	}
}
int main(){
//	freopen(".in","r",stdin);
	n = read();
	for(int i = 1; i < n; ++i){
		x = read(), y = read(), z = read();
		add(x,y,z);
		add(y,x,z);
	}
	dfs(1,-1);
	for(int i = 1; i <= n; ++i){
		printf("%d\n",c[i]);
	}
	return 0;
}

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

int main(void){

    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0; i<n; i++) cin >> h[i];

    sort(h.rbegin(), h.rend());

    unsigned long long count = 0;
    for(int i=k; i<n; i++) {
        count += h[i];
    }
    
    cout << count << endl;

    return 0;
}


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

typedef long long ll;
typedef long double Double;
#define rep(i,n) for(int i = 0; i < (int)(n) ; i++)

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


void solve(long long N, std::vector<std::string> s){
    map<string, int> memo;
    long long ans = 0;
    for(auto &x : s ){
        sort(x.begin(), x.end());
        ans += memo[x]++;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> s(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> s[i];
    }
    solve(N, std::move(s));
    return 0;
}



Measured memory_bytes: 18176
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Prog
    {
        const int MOD = 1000000007;
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Prog().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var p = cin.ReadIntArray(n);

            var sorted_p = p.OrderBy(x => x).ToArray();

            var diffCnt = 0;
            for (int i = 0; i < n; i++)
            {
                if (p[i] != sorted_p[i])
                {
                    diffCnt++;
                }
            }
            if (diffCnt <= 2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        public void ReadIntArrays(long N, out int[] A, out int[] B) { A = new int[N]; B = new int[N]; for (long i = 0; i < N; ++i) { A[i] = ReadInt; B[i] = ReadInt; } }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    A.at(i) = 0;
  }
   for (int i = 0; i < K; i++) {
     int d;
     cin >> d;
     vector<int> a(d);
     for (int j = 0; j < d; j++) {
     cin >> a.at(j);
     }
     for (int k = 0; k < d; k++) {
       for (int l = 0; l < N; l++) {
       if (a.at(k) == l + 1) {
         A.at(l)++;
       }
     }
     }
   }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) {
      sum++;
    }
  }
  cout << sum << endl;
}

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

int main(void){

    int n;
    cin>>n;
    int count=0;
    char a[100];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    //cin>>a;
   /* for(int i=0;i<n;i++){
         cout<<a[i]<<endl;
    }*/
   
    for(int i=0;i<n;i++){
      
        if(a[i] == 'Y'){
            count=1;
            //printf("a");
        }
    }
    if(count==1)cout<<"Four"<<endl;//printf("Four\n");
    else cout<<"Three"<<endl;//printf("Three\n");
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int N;
vii AB;
vi A, B, C;

int main() {
  io();
  
  cin >> N;
  fori(i, N) {
    int a;
    cin >> a;
    A.pb(a);
  }
  fori(i, N) {
    int b;
    cin >> b;
    B.pb(b);
  }
  fori(i, N) {
    AB.pp(A[i], B[i]);
  }
  fori(i, N-1) {
    int c;
    cin >> c;
    C.pb(c);
  }
  
  ui sum = 0;
  fori(i, N) {
    sum += B[i];
  }
  foris(i, 1, N) {
    if(A[i] - 1 == A[i - 1]) {
      sum += C[A[i-1] - 1];
    }
  }
  
  cout << sum;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	int *T = new int[N + 1];
	int *Ti = new int[N + 1];
	int A, A0, Ai;
	for (int i = 0; i < N; i++)
	{
		cin >> T[i];
		if (i == 0)
			Ti[i] = 1;
		else
		{
			if (T[i] != T[i - 1])
				Ti[i] = 1;
			else
				Ti[i] = T[i];
		}
		//cout << T[i] <<'\t'<< Ti[i] << endl;
	}
	long long result = 1;
	for (int i = 0; i <= N; i++)
	{
		int j = i - 1;
		if (i < N)
			cin >> A;
		if (j == N - 1)
			Ai = 1;

		//cout << Ai << '\t';
		if (j >= 0)
		{
			if (A0 == A&&j < N - 1)
				Ai = A0;
			else
				Ai = 1;
			if (Ti[j] == 1 && Ai == 1)
			{
				if (T[j] != A0)
				{
					result = 0;
					break;
				}
			}
			else if (Ti[j] == 1 && Ai>1)
			{
				if (T[j] > A0)
				{
					result = 0;
					break;
				}
			}
			else if (Ti[j] > 1 && Ai == 1)
			{
				if (T[j] < A0)
				{
					result = 0;
					break;
				}
			}
			else
			{
				if (T[j] < A0)
					result = (result % 1000000007)*T[j];
				else
					result = (result % 1000000007)* A0;
			}
			//cout << A0 << '\t' << Ai << endl;
		}

		A0 = A;
	}
	cout << result % 1000000007 << endl;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<string> s(n);
    vector<P> plu,neg;
    ll sum=0;
	rep(i,n){
		cin>>s[i];
        ll cnt=0,mi=0;
		rep(j,s[i].size()){
			if(s[i][j]=='(') cnt++;
			else cnt--;
            chmin(mi,cnt);
		}
        sum+=cnt;
        if(cnt>=0){
            plu.push_back(P(mi,i));
        }else{
            mi=0;
            cnt=0;
            for(int j=s[i].size()-1;j>=0;j--){
                if(s[i][j]==')') cnt++;
                else cnt--;
                chmin(mi,cnt);
            }
            neg.push_back(P(mi,i));
        }
	}
    if(sum!=0){
        cout<<"No"<<endl;
        return 0;
    }
    string t;
    sort(begin(plu),end(plu),greater<P>());
    sort(begin(neg),end(neg));
    rep(i,plu.size()) t+=s[plu[i].se];
    rep(i,neg.size()) t+=s[neg[i].se];
    ll cnt=0;
    rep(i,t.size()){
        if(t[i]=='(') cnt++;
        else cnt--;
        if(cnt<0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

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

int main(){

	int A, B;
	cin >> A >> B;
	int tmp;
	int count=0;

	for(int i = A; i <= B; i++){
		tmp = i;
		int reverse = 0;
		int hitoketa;

		while(tmp != 0){ //tmpが0になるのは一番上の桁まで到達したとき
			hitoketa = tmp % 10; //10で割ったのあまりは一番下の桁；
			reverse = reverse*10 + hitoketa;
			tmp = tmp / 10; //次の桁
		}

		if(i == reverse){
			count++;
		}

	}
	cout << count << endl;

	return 0;

}

Measured memory_bytes: 256
s=int(input())
def f(x):
    if x%2==0:
        return x//2
    else:
        return 3*x+1
a=s
ans=[s]
for i in range(10**6+5):
    a=f(a)
    if a in ans:
        print(i+2)
        exit()
    ans.append(a)
    
    


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

vector<int> prime;
vector<int> ls;

void sieve(int N){
    prime.resize(N+1,1);
    prime[0] = prime[1] = 0;
    for(int i=2;i*i<=N;i++){
        for(int j=i*i;j<=N;j+=i){
            prime[j] = 0;
        }
    }
    for(int i=2;i<=N;i++){
        if(prime[i])ls.push_back(i);
    }
}

int main() {
    sieve(int(1e5));
    int n;
    while(cin >> n, n){
        int p, q;
        for(int i=0;ls[i]<=n-2;i++){
            if(ls[i+1]-ls[i]==2){
                p = ls[i];
                q = ls[i+1];
            }
        }
        cout << p << " " << q << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
// aarsh01rsh@gmail.com
// Aarsh Sharma
#include<bits/stdc++.h>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}
string to_string(char ch) {
  string s(1, ch);
  return '\'' + s + '\'';
}
string to_string(const char *s) {
  return to_string((string)s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define f(i, x, n) for (int i = x; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long int ll;
#define int ll
typedef pair<ll, ll> pll;
typedef vector<vector<ll>> matrix;
typedef vector<ll> vll;

const ll mod = 1e9 + 7;
const ll inf = LLONG_MAX;
const ll N = 1e5 + 10;

int32_t main() {
  fast_io();

  string s, t; cin >> s >> t;
  int ans = 0;
  f (i, 0, 3) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 256
bingo = []
for i in range(3):
    a = list(map(int, input().split()))
    bingo += a
tmp = [0] * 9
n = int(input())
for i in range(n):
    b = int(input())
    if b in bingo:
        tmp[bingo.index(b)] = 1

if tmp[4]:
    if (tmp[0] and tmp[8]) or (tmp[1] and tmp[7]) or (tmp[2] and tmp[6]) or (tmp[3] and tmp[5]):
        print("Yes")
        exit()
if tmp[0]:
    if (tmp[1] and tmp[2]) or (tmp[3] and tmp[6]):
        print("Yes")
        exit()
if tmp[8]:
    if (tmp[6] and tmp[7]) or (tmp[2] and tmp[5]):
        print("Yes")
        exit()
print("No")

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

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

using namespace std;

long long gcd(long long a, long long b){
    if (a % b == 0)return(b);
    else return(gcd(b, a % b));
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}


int main() {
	long long N, M;
	cin >> N >> M;

	vector<long long> A;
	rep(i, N) {
		long long num;
		cin >> num;
		A.push_back(num / 2);
	}
	// 重複要素の削除
	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());

	long long a = 1;
	rep(i, A.size()) {
		a = lcm(a, A[i]);
	}

	rep(i, A.size()) {
		if ((a / A[i]) % 2 == 0) {
			cout << 0;
			return 0;
		}
	}
	long long ans = M / a;
	if (ans % 2 == 0)ans /= 2;
	else ans = (ans + 1) / 2;
	cout << ans;
	
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int a,b,c;cin>>a>>b>>c;
    if(b>=a){
        b=a;
    }
    if(c-(a-b)>=0)cout<<c-(a-b);
    else cout<<0;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
typedef pair<char,char> P;
int n,q;
string s;
P td[200005];
int ans;
int ans2;


bool cimu(int pos, bool swi) {
  for(int i = 0; i < q; i++) {
    if(td[i].first != s[pos]) continue;
    if(td[i].second == 'L') pos--;
    else pos++;
    if(pos < 0 && swi) return true;
    else if(pos >= n && !swi) return true;
  }

  return false;
}
  
void solve() {
  int l = -1, r = n;
 
  while(r - l > 1) {
    int mid = (l + r) / 2;
    // cout << "l1 = "<<l <<"  r1 = "<<r<< endl;
    if(cimu(mid,true) == true) l = mid;
    else r = mid;
  }
  ans = l;
  //  cout << ans << endl;
  l = -1; r = n;
  while(r - l > 1) {
    int mid = (l + r) / 2;
    //cout << "l2 = "<<l <<"  r2 = "<<r<< endl;
    if(cimu(mid,false) == true) r = mid;
    else l = mid;
  }
  ans2 = n - l;

  return;
}
  
int main() {
  cin >> n >> q >> s;

  for(int i = 0; i < q; i++) cin >> td[i].first >> td[i].second;

  solve();
  cout << n - (ans + ans2) << endl;
}
  
  


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

int main(){
        int n;
        while( cin >> n && n){
                int count = 0;
                for(int i=1; i<n; i++){
                        int add = 0, sum = 0;
                        while(add < n){
                                sum += (i + add++);
                                if(sum > n) break;
                                if(sum == n) count++;
                        }
                }
                cout << count << endl;
        }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
typedef long long ll;
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int n;cin >> n;
    ll v = 0,e = 0;
    FOR(i,1,n+1)v+= ll(i)*(n-i+1);
    REP(i,n-1){
        ll a,b;cin >> a >> b;
        if(a>b)swap(a,b);
        e+=a*(n-b+1); 
    }
    ll ans = v-e;
    cout << ans << endl;
}//https://atcoder.jp/contests/abc173/tasks/abc173_f

Measured memory_bytes: 3620
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };



int main() {
    string s;
    cin >> s;
    bool ans = true;
    while (s.size() > 1) {
        if (s.substr(s.size() - 5) == "erase" || s.substr(s.size() - 5) == "dream") {
            s.erase(s.size() - 5);
        }
        else if (s.substr(s.size() - 6) == "eraser") {
            s.erase(s.size() - 6);
        }
        else if (s.substr(s.size() - 7) == "dreamer") {
            s.erase(s.size() - 7);
        }
        else {
            ans = false;
            break;
        }
    }
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K, A, B, k=1;
  bool flag = false;
  cin >> K >> A >> B;
  int baisuu=1;
  while(baisuu<=B){
    baisuu = k * K;
    if(A<=baisuu&&baisuu<=B) flag = true;
    k++;
  }
  if(flag) cout << "OK" << endl;
  else cout << "NG" << endl;
  return 0;
}

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

using namespace std;

typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli>> mat;
typedef vector<unordered_map<lli,lli>> graph;

lli n,k;
mat ab;

int main(){
  cin >> n >> k;
  ab = mat(n,vll(2));
  for(lli i = 0;i < n;i++) cin >> ab[i][0] >> ab[i][1];
  sort(ab.begin(),ab.end());
  lli i = 0;
  while(k > 0){
    k -= ab[i][1];
    i++;
  }
  cout << ab[i-1][0] << endl;
  return 0;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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 N 4
#define N2 16

static const int dx[4] = { 0, -1, 0, 1};
static const int dy[4] = { 1, 0, -1, 0};
static const char dir[4] = { 'r', 'u', 'l', 'd'};
int MDT[N2][N2];

struct Puzzle {
  int f[N2], space, MD;
  int cost;

  bool operator < (const Puzzle &p) const {
    rep(i, 0, N2) {
      if (f[i] == p.f[i]) continue;
      return f[i] < p.f[i];
    }
    return false;
  }
};

struct State {
  Puzzle puzzle;
  int estimated;
  bool operator < (const State &s) const {
    return estimated > s.estimated;
  }
};

int getAllMD(Puzzle pz) {
  int sum = 0;
  rep(i, 0, N2) {
    if (pz.f[i] == N2) continue;
    sum += MDT[i][pz.f[i] - 1];
  }
  return sum;
};

int astar(Puzzle s) {
  priority_queue<State> PQ;
  s.MD = getAllMD(s);
  s.cost = 0;
  map<Puzzle, bool> V;
  Puzzle u, v;
  State initial;
  initial.puzzle = s;
  initial.estimated = getAllMD(s);
  PQ.push(initial);

  while (!PQ.empty()) {
    State st = PQ.top(); PQ.pop();
    u = st.puzzle;

    if (u.MD == 0) return u.cost;
    V[u] = true;

    int sx = u.space / N;
    int sy = u.space % N;
    rep(r, 0, 4) {
      int tx = sx + dx[r];
      int ty = sy + dy[r];
      if (tx < 0 || ty < 0 || tx >= N || ty >= N) continue;
      v = u;

      v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];
      v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];

      swap(v.f[sx * N + sy], v.f[tx * N + ty]);
      v.space = tx * N + ty;
      if (!V[v]) {
        v.cost++;
        State news;
        news.puzzle = v;
        news.estimated = v.cost + v.MD;
        PQ.push(news);
      }
    }
  }
  return -1;
};

int main() {
  rep(i, 0, N2) {
    rep(j, 0, N2) {
      MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
    }
  }

  Puzzle in;
  rep(i, 0, N2) {
    cin >> in.f[i];
    if (in.f[i] == 0) {
      in.f[i] = N2;
      in.space = i;
    }
  }

  cout << astar(in) << endl;

  return 0;
};



Measured memory_bytes: 257720
# coding: utf-8
# Your code here!
s = input()
t = input()
temp = list(s)
flag = 0
for i in range(len(s)):
    # test = str(temp.insert(0,temp.pop()))
    test = temp.pop()
    temp.insert(0,test)
    test = "".join(temp)
    # print(i,test)
    if test == t:
        print("Yes")
        flag = 1
        break
if not flag:
    print("No")
    

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N, M; cin >> N >> M;
    vector<int> A(N);
    for(int i=1; i<=N; i++) A[i-1] = i;
    int cnt = 0;
    int mid = N / 2;
    if(N % 2 == 0){
        rep(i,N){
            printf("%d %d\n", A[i], A[mid-1-i]);
            cnt++; if(cnt >= M) break;
            printf("%d %d\n", A[mid+1+i], A[N-1-i]);
            cnt++; if(cnt >= M) break;
        }
    }else{
        rep(i,N){
            printf("%d %d\n", A[i], A[mid-i]);
            cnt++; if(cnt >= M) break;
            printf("%d %d\n", A[mid+1+i], A[N-1-i]);
            cnt++; if(cnt >= M) break;
        }
    }
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
#define vi vector<int>
long long mod=1000000007;
//int count=INT_MAX;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    //int t=testcases;
    while(testcases--){
        int n,x,t;
        cin>>n>>x>>t;
        int d=n/x;
        if(n%x!=0) d++;
        cout<<d*t;
    }               

    return 0;
}

Measured memory_bytes: 3608
n=int(input())
p = list(map(int,input().split()))
# print(p)
min=p[0]
ans=0

for i in range(n):
    if i == 0:
        ans+=1
        continue
    if p[i] > min:
        continue
    if p[i] < min:
        min=p[i]
        ans+=1

print(ans)


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

int main()
{
    string str;
    cin>>str;
    int i, j, sum=0;
    vector<int> v;

    for(i=0; i<str.size(); i++){
        if(str[i] == 'A' || str[i] == 'G' || str[i] == 'C' || str[i] == 'T'){
            sum= sum + 1;
        }
        else{
            v.push_back(sum);
            sum=0;
        }
    }
    v.push_back(sum);
    sort(v.begin(), v.end());


    cout<<v[v.size()-1];

}


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


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string O, E;
    cin >> O >> E;
    rep(i, O.size() + E.size()) {
        if (i % 2 == 0) cout << O[i/2];
        else cout << E[i/2];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main (String [] args) {

		Scanner sc = new Scanner (System.in);

		String s = sc.next();
		String t = sc.next();

		int count = 0;

		if (s.charAt(0)==t.charAt(0)) {
			count++;
		}
		if (s.charAt(1)==t.charAt(1)) {
			count++;
		}
		if (s.charAt(2)==t.charAt(2)) {
			count++;
		}

		System.out.println(count++);
	}
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n, a,b,c,d;
    cin >> n >> a >> b>>c>>d;
    string s;
    cin >> s;
    int mode = 0;
    FOR(i,a-1,c){
        if(s[i]=='#'){
            if(mode==1){
                cout << "No" << "\n";
                return 0;
            }
            mode = 1;
        }else{
            mode = 0;
        }
    }
    mode = 0;
    FOR(i, b - 1, d)
    {
        if (s[i] == '#')
        {
            if (mode == 1)
            {
                cout << "No"
                     << "\n";
                return 0;
            }
            mode = 1;
        }
        else
        {
            mode = 0;
        }
    }
    mode = 0;
    if(d<c){
        FOR(i, b - 2, d+1)
        {
            if (s[i] == '#')
            {
                mode = 0;
            }
            else
            {
                mode += 1;
                if (mode == 3)
                {
                    cout << "Yes"
                         << "\n";
                    return 0;
                }
            }
        }
        cout << "No"
             << "\n";
        return 0;
    }  

    cout << "Yes"<<"\n";

    return 0;
}

Measured memory_bytes: 640
line = raw_input()
N, M, X, Y = [int(s) for s in line.split(' ')]
line = raw_input()
xn = [int(s) for s in line.split(' ')] + [X]
line = raw_input()
ym = [int(s) for s in line.split(' ')] + [Y]

x_edge = max(xn)
y_edge = min(ym)

print 'No War' if x_edge < y_edge else 'War'


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

int main(){
  ll N, K;
  cin >> N >> K;
  vector<ll> p(N);
  for (int i = 0; i < N; ++i) cin >> p[i];
  ll out = 0;
  sort(p.begin(), p.end());
  for (int i = 0; i<K; ++i){
    out += p[i];
  }
  cout <<out << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  string s; cin >> s;
  int n = s.size();
  string t = "";
  rep(i,n) if (s[i]!='x') t+=s[i];
  int m = t.size();
  string u = t;
  reverse(all(u));
  
  if (t!=u) {
    cout << -1 << endl;
    return 0;
  }
  int a[(m+1)/2] = {};
  int idx = 0;

  rep(i,(m+1)/2) {
    int cnt = 0;
    while (s[idx]=='x') cnt++, idx++;
    a[i] = cnt;
    idx++;
  }
  idx = n-1;
  rep(i,(m+1)/2) {
    int cnt = 0;
    while (s[idx]=='x') cnt++, idx--;
    a[i] -= cnt;
    idx--;
  }
  int ans = 0;
  rep(i,(m+1)/2) ans +=  abs(a[i]);
  cout << ans << endl;
  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4040
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    getline(cin, s);
    int w;
    cin >> w;
    for (unsigned int i = 0; i != s.length(); i++) {
        if (i % w == 0)
            cout << s[i];
    }
    return 0;
}


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

int main() {
  int alice = 0, bob = 0;
  int N;
  cin >> N;
  vector<int> a(N);
  
  for(int i=0; i<N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for(int i=0; i<N; i++){
    if (i%2 == 0) alice += a[N-1-i];
    else bob += a[N-1-i];
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String ans = solve(n);

        System.out.println(ans);
    }

    public static String solve(int n) {
        String str = String.valueOf(n);
        char[] chars = str.toCharArray();
        int sum = 0;
        for (char item: chars) {
            sum += Character.getNumericValue(item);
        }
        String answer = (n % sum == 0) ? "Yes" : "No";
        return answer;
    }



}


Measured memory_bytes: 22864
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int);
void init();
void printList();
void deleteNode(NodePointer);
void deleteFirst();
void deleteLast();
void delete(int);
void insert(int);
 
main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++; 
      }
      size--;
    }
  }
 
  printList();
  return 0;
}
 
 
NodePointer listSearch(int key){
  NodePointer x;
  x=nil->next;
  while(x!=nil && x->key!=key){
    x=x->next; 
 }
  return x;
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}
 
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}
 
void deleteLast(){
  NodePointer t = nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}
 
void delete(int key){
  NodePointer x;
    x=listSearch(key);
    if ( x == nil ) return;
    deleteNode(x);
}
 
 
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

Measured memory_bytes: 31788
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1LL<<50
#define fst first
#define snd second
#define pb push_back
#define int long long
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(int itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(int itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define debug(x)  cout << #x << " = " << (x) << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  int n;
  cin >> n;
  
  int cnt = 0;
  REP(i,n){
    int a;
    cin >> a;
    if(a % 2 == 1) cnt++;
  }
  
  if(cnt % 2 == 0) cout << "YES" << endl;
  else 	 		   cout << "NO" << endl;

  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	string S=in<string>();
	int v=700;
	for(int i=0;i<3;i++){
		if(S[i]=='o') v+=100;
	}
	cout << v << endl;
	return 0;
}


Measured memory_bytes: 256