akhauriyash/Code-Regression huggingface dataset:
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)


N, M = map(int, input().split())
S = input()
T = input()
G = int(gcd(N, M))
f = 0
for i in range(G):
    n, m = int(i * N / G), int(i * M / G)
    #print(n, m, S[n], T[m])
    if S[n] != T[m]:
        f = 1
        break

print(int(N * M / G) if f == 0 else -1)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    long long a, b, x, ans;

    cin >> a >> b >> x;

    ans = b / x - a / x;
    if((a % x) == 0) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.Closeable;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author HBonsai
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BI18n solver = new BI18n();
        solver.solve(1, in, out);
        out.close();
    }

    static class BI18n {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            out.println(s[0] + String.valueOf(s.length - 2) + s[s.length - 1]);
        }

    }

    static class FastScanner implements Closeable {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public void close() {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}



Measured memory_bytes: 21204
x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
right = x
left = x
while True:
    if left in p:
        left -= 1
    else:
        print(left)
        break
    if right in p:
        right += 1
    else:
        print(right)
        break

Measured memory_bytes: 61848
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;


int main()
{
    ll n,m;
    cin >> n >> m;

    ll ans = (n-2)*(m-2);
    if(ans<0)ans=0;
    if(n==1&&m>2)ans=m-2;
    else if(m==1&&n>2)ans=n-2;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#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 = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,x;
  cin >> N >> x;
  int ans=0;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  sort(a,a+N);
  for(int i=0;i<N;i++){
    x-=a[i];
    ans++;
    if(x==0){
      break;
    }
    if(x<0){
      ans--;
      break;
    }
  }
  if(x>0) ans--;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
gi=->{gets.split.map &:to_i}
N,M=gi[]
dp=[1<<28]*(1<<N)
dp[0]=0
M.times{
	a,b=gi[]
	c=gi[].inject(0){|s,x|s|1<<(x-1)}
	(1<<N).times{|i|dp[i|c]=[dp[i|c],dp[i]+a].min}
}
p dp[(1<<N)-1]<1<<28?dp[(1<<N)-1]:-1

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
const ll mod=1000000007;

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

    int N;
    string s[2];
    cin >> N >> s[0] >> s[1];

    ll ans = 0;
    if (s[0][0] == s[1][0]) {
        ans += 3;
    } else {
        ans += 6;
    }

    for (int i = 1; i < N; i++) {
        if (s[0][i-1] == s[1][i-1]) {
            ans *= 2;
        } else {
            if (s[0][i] != s[1][i] && s[0][i-1] != s[0][i]) {
                ans *= 3;
            }
        }
        ans %= mod;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int res = n;

		for(int i=0; i <= n; i++) {
			int cc = 0;
			int t=i;
			while(t>0) {
				cc+=t%6;
				t /= 6;
			}
			t = n-i;
			while(t>0) {
				cc+=t%9;
				t /= 9;
			}
			if(res > cc) {
				res = cc;
			}
		}

		System.out.println(res);


	}

}


Measured memory_bytes: 21844
import scala.io.StdIn

object Main extends App {

  def countDivisor(n: Int): Int = (1 to n).count( d => (n % d) == 0 )

  val n = StdIn.readLine.toInt
  val ans = (105 to n by 2).count(i => countDivisor(i) == 8)
  println(ans)
}

Measured memory_bytes: 27192
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        char aa = a.charAt(0);
        char bb = b.charAt(0);
        char cc = c.charAt(0);

        System.out.println(aa+""+bb+""+cc);
    }
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    int sum = 0;
    int keta = 0;
    int a, b;
    for (int i = 0; i < N; i++) {
        cin >> a >> b;
        sum += a * b;
        keta += b;
    }
    sum = (sum - 1) / 9;
    cout << sum + keta - 1 << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

using mint = modint998244353;

struct S {
  mint a;
  mint base;
  mint size;
};

using F = int;
const F ID = 998244354; 

S op(S l, S r) { return S{l.a + r.a, l.base + r.base, l.size + r.size};}

S e() { return S{0, 0, 0};}

S mapping(F f, S x) {
  if (f != ID) x.a = x.base * f;
  return x;
}

F composition(F f, F g) { return (f == ID ? g : f);}

F id() { return ID; }

int main() {
  int n, q;
  cin >> n >> q;
  vector<S> a(n);
  mint cur = 1;
  for (int i = n - 1; i >= 0; i--) {
    a[i] = {cur, cur, 1};
    cur *= 10;
  }
  
  lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);
  //cout << seg.all_prod().a.val() << endl;
  while (q--) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    seg.apply(l, r, d);
    //cout << "ans ";
    cout << seg.all_prod().a.val() << endl;
  }
  return 0; 
}

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

using ll=long long;
using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> x(n);
    rep(i,n) cin>>x[i];
    ll sum=0;
    
    rep(i,n){
        sum+=min(x[i],k-x[i])*2;
    }
    
    cout<<sum<<endl;
    return 0;
}

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

int N;
int index(int num, bool search[]) {
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (i == num) return res;
    if (search[i]) res++;
  }
}

int main() {
  int P[8], Q[8];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> P[i];
  for (int i = 0; i < N; i++) cin >> Q[i];
  int factorial = 1, dif = 0; bool p[N], q[N];
  for (int i = 0; i < N; i++) {
    factorial *= i + 1;
    p[i] = q[i] = true;
  }
  for (int i = 0; i < N; i++) {
    factorial /= N - i;
    dif += factorial * (index(P[i]-1, p) - index(Q[i]-1, q));
    p[P[i]-1] = q[Q[i]-1] = false;
  }
  dif = abs(dif);
  cout << dif << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d%d",&a,&b);
  if(a<b){
    for(int i=0;i<b;i++) printf("%d",a);
  }
  else{
    for(int i=0;i<a;i++) printf("%d",b);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

typedef long long ll;

int main() {
#if __APPLE__
    //freopen("A.in", "r", stdin);
    //freopen("A.out", "w", stdout);
#endif

    int n;
    scanf("%d", &n);

    vector<int> a(n + n + n);
    for (size_t i = 0; i < a.size(); ++i) {
        scanf("%d", &a[i]);
    }

    multiset<int> q(a.begin(), a.begin() + n), f, p(a.begin() + n, a.end());
    ll sum1 = 0;
    for (int i = 0; i < n; ++i) {
        sum1 += a[i];
    }
    ll sum2 = 0;
    for (int i = 0; i < n; ++i) {
        auto it = p.begin();
        f.insert(*it);
        sum2 += *it;
        p.erase(it);
    }

    ll ans = sum1 - sum2;
    for (int i = n; i < n + n; ++i) {
        auto itf = f.find(a[i]);
        auto itp = p.find(a[i]);
        if (itf != f.end()) {
            sum2 -= a[i];
            f.erase(itf);
            auto it = p.begin();
            f.insert(*it);
            sum2 += *it;
            p.erase(it);
        } else if (itp != p.end()) {
            p.erase(itp);
        }
        sum1 += a[i];
        q.insert(a[i]);
        sum1 -= *q.begin();
        q.erase(q.begin());
        ans = max(ans, sum1 - sum2);
    }

    printf("%lld\n", ans);
}


Measured memory_bytes: 15488
#include <iostream>
#include <vector>

class DisjointSet {
public:
    std::vector<int> rank, p;

    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }

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

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) {
                rank[y]++;
            }
        }
    }

    int findSet(int x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};

int main() {
    int n, a, b, q;
    int t;

    std::cin >> n >> q;
    DisjointSet ds = DisjointSet(n);

    for (int i = 0; i < q; i++) {
        std::cin >> t >> a >> b;
        if (t == 0) ds.unite(a, b);
        else if (t == 1) {
            if (ds.same(a, b)) std::cout << 1 << std::endl;
            else std::cout << 0 << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3196
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in a:
    b[i-1]+=1
alls=0
for i in b:
    if i>1:
        alls+=i*(i-1)//2
for i in a:
    print(alls-b[i-1]+1)

Measured memory_bytes: 24748
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int m = sc.nextInt();
        int n = sc.nextInt();
        
        System.out.println(iterationPowMod(m,n));
    }
    
	static int iterationPowMod(long x, long n){
		int mod = 1000000007;
	    long sum = 1;
	    while(n>0){
	        if((n&1)== 1){  //ビットが立っていたら
	            sum *= x;        //x^2^k1 * x^2^k2 * x^2^k3 * ・・・
	            sum %= mod;
	        }
	        x *= x;              //((x^2)^2)^2・・・
	        x %= mod;
	        n >>= 1;
	    }
	    return (int)sum;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 24296
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {
        static long mod = (long)Math.Pow(10, 9) + 7;

        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] aString = Console.ReadLine().Split(' ');
            long[] rains = new long[N];
            long[] surpluses = new long[N];
            long[] ans = new long[N];


            for (int i = 0; i < N; i++)
            {
                rains[i] = int.Parse(aString[i]);
                if (i % 2 == 1)
                {
                    surpluses[0] += rains[i];
                }
                else if (i != 0)
                {
                    surpluses[1] += rains[i];
                }
            }
            long sum = rains.Sum() / 2;

            ans[0] = (sum - surpluses[0])*2;
            ans[1] = (sum - surpluses[1])*2;


            for (int i = 2; i < N; i++)
            {
                surpluses[i] = surpluses[i - 2] - rains[i - 1] + rains[(i + N - 2) % N];
                ans[i] = (sum - surpluses[i])*2;
            }
            Console.WriteLine(string.Join(" ",ans));
            Console.ReadLine();
        }

        private static long[] Read(string input)
        {
            string[] strings = input.Split(' ');
            long num = strings.Length;
            long[] ints = new long[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = long.Parse(strings[i]);
            }

            
            return ints;
        }
    }
}


Measured memory_bytes: 31836
// use std::collections::BitVec;

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

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

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

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

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

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

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

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

fn main(){

    input!{
        n: usize,
        m: usize,
        v: [(usize,String);m],
    }

    let mut is_ac: Vec<bool> = Vec::with_capacity(n);
    let mut pena_num: Vec<usize> = Vec::with_capacity(n);
    for _ in 0..n {
        is_ac.push(false);
        pena_num.push(0);
    }
    let mut ac_num = 0;
    for i in 0..m {
        let prob_num = v[i].0 -1;
        if is_ac[prob_num]==false && v[i].1=="AC" {
            ac_num += 1;
            is_ac[prob_num] = true;
        } else if is_ac[prob_num]==false && v[i].1=="WA" {
            pena_num[prob_num] += 1;
        }
    }
    
    let mut pena_sum = 0;
    for i in 0..n {
        if is_ac[i]==true {
            pena_sum += pena_num[i];
        }
    }

    println!("{} {}", ac_num, pena_sum);

}

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

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<int> dp(n);
  for(int i=1; i<n; i++){
    if(i==1){
      dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
    }else{
      dp[i]=min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    }
  }
  cout << dp[n-1] << endl;
}

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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
    ll n;
    cin>>n;
    Array h(n);
    REP(i,n) cin>>h[i];
    map<ll,ll> mp1,mp2;
    ll con=0;
    REP(i,n){
        con+=mp1[i-h[i]];
        con+=mp2[i+h[i]];
        mp1[i+h[i]]++;
        mp2[i-h[i]]++;
    }
    cout<<con<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 50156
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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

int main(){
    int const INF = 100000000;
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int mn = INF;
    int mnidx;
    int mx = -INF;
    int mxidx;
    vector<P> ans;
    rep(i, n){
        if (a[i] >= mx){
            mx = a[i];
            mxidx = i;
        }
        if (a[i] <= mn){
            mn = a[i];
            mnidx = i;
        }
    }
    // cout << mx << " " << mn << endl;
    if (abs(mx) > abs(mn)){
        rep(i, n){
            if (i != mxidx && a[i] < 0){                                
                a[i] += mx;
                ans.push_back(P(mxidx, i));
            }
        }
        if (mxidx != 0){
            a[0] += mx;
            ans.push_back(P(mxidx, 0));
        }
        for (int i = 1; i < n; i++){
            a[i] += a[i-1];
            ans.push_back(P(i - 1, i));
        }
    }else{
        rep(i, n){
            if (i != mnidx){
                a[i] += mn;
                ans.push_back(P(mnidx, i));
            }
        }
        if (mnidx != n - 1){
            a[n-1] += mn;
            ans.push_back(P(mnidx, n - 1));        
        }
        for (int i = n - 2; i >= 0; i--){
            a[i] += a[i+1];
            ans.push_back(P(i + 1, i));
        }
    }
    // rep(i, n) cout << a[i] << " ";
    // cout << endl;
    cout << ans.size() << endl;
    rep(i, ans.size()){
        cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
    }
}

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

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

  // ここにプログラムを追記
  int a , b , c , d ;
  
  d=0;
  for(int i=1; i<=N; i++){
    cin>> a >> b ;
    
    c=b-a+1;
    
    d+=c;
  }
  
  cout << d << endl ;
  
      
  
}



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

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

    int left = 0;
    int right = 100001;
    for (int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;

        left = max(left, l);
        right = min(right, r);
    }

    cout << max(right - left + 1, 0) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
int H,N,sum=0,i,a;
scanf("%d %d",&H,&N);

for(i=1;i<=N;i++)
{
    scanf("%d",&a);
    sum+=a;
}
if(sum>=H)
printf("Yes");
 else
    printf("No");

    return 0;
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
str s;
void ans2();
void ans3();
signed main()
{
    /*
    cin >> s;
    rep(i,0,s.size()){
        if(s[i]==',')cout << " ";
        else cout << s[i];
    }
    cout << endl;
*/
 //   str ss;
 //   cin >> ss;
 //   cout << ss.size() << endl;
    ans2();
      //  ans3();
    return 0;
}
void ans2(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    str a1="";
    str a2="";
    str b1="";
    str b2="";
    rep(i,b,d){
        a1+='U';
        b1+='D';
    }
    rep(j,a,c){
        a2+='R';
        b2+='L';
    }
    str ans=a1;
    ans+=a2;
    ans+=b1;
    ans+=b2;
    ans+='L';
    ans+=a1;
    ans+='U';
    ans+=a2;
    ans+="RDR";
    ans+=b1;
    ans+='D';
    ans+=b2;
    ans+="LU";
    cout << ans << endl;
 //   cout << ans.size() << endl;
    return ;
}
/*
set<string> an;
void ans3(){
    int n,m;
    cin >> n >> m;
    rep(i,0,n){
        rep(j,0,n){
            if((i+j)>=(m-n)&&(i+j)<=m){
                str ss=to_string(i);
                ss+='#';
                ss+=std::to_string(j);
                ss+='#';
                ss+=std::to_string(m-(i+j));
                an.insert(ss);
            }
        }
    }
    cout << ss.size() << endl;
    return;
}*/



Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  int a[3];
  int x;
  scanf("%d %d %d",&a[0],&a[1],&a[2]);

  for(int i=0;i<3;i++){
    for(int j=i+1;j<3;j++){
        if(a[i]>a[j]){
          x=a[i];
          a[i]=a[j];
          a[j]=x;
        }
    }
  }
  printf("%d %d\n",a[0],a[2]);
  return 0;
}




Measured memory_bytes: 2116
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;


typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int mxn  = 1e5+10;
vector<vi> adj(mxn);
vector<int> par(mxn);
vector<int> vis(mxn);


void solve(){
	int n,m;
	cin >> n >> m;
	for(int i =0;i<m;i++){
		int u,v;
		cin >> u >> v;
		--u,--v;
		adj[u].pb(v);
		adj[v].pb(u);
	}

	queue<int> q;
	q.push(0);
	while(!q.empty()){
		int u = q.front();
		q.pop();
		vis[u] = 1;
		for(auto v:adj[u]){
			if(!vis[v]){
				q.push(v);
				vis[v]=1;
				par[v+1] = u+1;
			}
		}
	}
	cout << "Yes" << endl;
	for(int i =2;i<=n;i++){
		cout << par[i] << endl;
	}
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 10784
import java.util.Scanner;
 
public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new aoj107().doIt();
	}
	class aoj107{
		boolean ans(int a,int b,double r){
			for(double i = 0;i < 90;i++){
				double sin = 2*r*Math.sin(Math.toRadians(i));
				double cos = 2*r*Math.cos(Math.toRadians(i));
				if(a < sin && b < cos)return true;
			}
			return false;
		}
		void doIt() {
			while(true){
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				if(a+b+c == 0)break;
				int cnt = sc.nextInt();
				for(int i = 0;i < cnt;i++){
					double r = sc.nextDouble();
					if(ans(a,b,r)){
						System.out.println("OK");
					}else if(ans(b,a,r)){
						System.out.println("OK");
					}else if(ans(c,a,r)){
						System.out.println("OK");
					}else if(ans(a,c,r)){
						System.out.println("OK");
					}else if(ans(c,b,r)){
						System.out.println("OK");
					}else if(ans(b,c,r)){
						System.out.println("OK");
					}else{
						System.out.println("NA");
					}
				}
			}
		}
	}
}

Measured memory_bytes: 20152
#include<bits/stdc++.h>
using namespace std;
int n;
struct data{
    int to,nxt;
}mp[200200];
int head[100100],cnt;
void link(int x,int y)
{
    mp[++cnt].to=y;
    mp[cnt].nxt=head[x];
    head[x]=cnt;
}
int d[100100];
char ch[100100];
bool col[100100];
int val[100100];

bool del[100100];
queue<int>q;
void Topsort()
{
    for(int i=1;i<=n;++i)
        if(d[i]==1&&!col[i])q.push(i),del[i]=1;
    int x,v;
    while(!q.empty())
    {
        x=q.front();q.pop();
        for(int i=head[x];i;i=mp[i].nxt)
        {
            v=mp[i].to;d[v]--;
            if(d[v]==1&&!col[v])
                q.push(v),del[v]=1;
        }
    }
}
int sum;
int ans;
int f[100100][2];//0:不包含叶子的最小链,1:包含叶子的最小链
void dfs(int x,int fa)
{
    int v;
    int cx=(val[x]?-1:1);
    sum+=val[x]+2;
//    cout<<"x: "<<x<<" fa: "<<fa<<endl;
    for(int i=head[x];i;i=mp[i].nxt)
        if(mp[i].to!=fa&&!del[mp[i].to])
        {
            v=mp[i].to;
            dfs(v,x);
            ans=min(ans,f[x][0]+f[v][1]-1+cx);
            ans=min(ans,f[x][1]+f[v][0]-1+cx);
            f[x][0]=min(f[x][0],f[v][0]-1);
            f[x][1]=min(f[x][1],f[v][1]-1);
        }
    if(d[x]!=1)f[x][0]+=cx;
    f[x][1]+=cx;
}
int main()
{
    scanf("%d",&n);
    int xx,yy;
    for(int i=1;i<n;++i)
    {
        scanf("%d%d",&xx,&yy);
        link(xx,yy),link(yy,xx);
        d[xx]++;d[yy]++;
    }
    scanf("%s",ch+1);
    for(int i=1;i<=n;++i) col[i]=(ch[i]=='W');
    Topsort();
    for(int i=1;i<=n;++i)
        val[i]=((d[i]&1)^col[i]);
//    cout<<"d[1]: "<<d[1]<<endl;
//    for(int i=1;i<=n;++i)cout<<val[i]<<" ";cout<<endl;
    int fl=1;
    for(int i=1;i<=n;++i)
        if(!del[i])
        {
            fl=0;
            dfs(i,0);
            break;
        }
    if(fl)
    {
        puts("0");
        return 0;
    }
//    cout<<"sum: "<<sum<<endl;
    ans+=sum-2;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define INF 0x3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define pair pair<int,int>
#define C(a) cout<<a<<endl;
#define CY cout<<"YES"<<endl;
#define CN cout<<"NO"<<endl;
#define Cy cout<<"Yes"<<endl;
#define Cn cout<<"No"<<endl;
#define ull unsigned long long
#define me(a) memset(a,0,sizeof(a));
#define my(a,b) memcpy(a,b,sizeof(b));
#define cio ios::sync_with_stdio(false)
ll mod=1e9+7;
ll gcd(ll a,ll b){return (a%b==0) ? b : gcd(b,a%b);}
int main(){
	
	ll a;
	cin>>a;
	if(a>=30)
	{
		Cy;
	}else{
		Cn;
	}
	return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 3005;
const int MOD = 1e9 + 7;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

template <typename T> inline void cmin(T &x, T y) {
	if (x > y) x = y;
}

template <typename T> inline void cmax(T &x, T y) {
	if (x < y) x = y;
}

char s[MAXN];
int n, m, sum[MAXN], rbd[MAXN];
int dp[MAXN][MAXN];

inline void Inc(int &x, int y) {
	x += y; if (x >= MOD) x -= MOD;
}

void init() {
	read(n); read(m);
	scanf("%s", s + 1);
	for (int i=1;i<=n;++i) {
		sum[i] = sum[i-1] + s[i] - '0';
		rbd[i] = i;
	}
	sum[n+1] = sum[n]; rbd[n+1] = n+1;
	for (int i=1;i<=m;++i) {
		int l, r;
		read(l); read(r);
		cmax(rbd[l], r);
	}
	for (int i=1;i<=n;++i) {
		cmax(rbd[i], rbd[i-1]);
	}
}

void solve() {
	dp[1][sum[rbd[1]]] = 1;
	for (int i=1;i<=n;++i) {
		for (int j=0;j<=n;++j) {
			int x = dp[i][j];
			if (!x) continue;
			int l = rbd[i] + 1, r = rbd[i+1];
			int cnt1 = j, cnt0 = rbd[i] - i + 1 - j;
			if (cnt0) Inc(dp[i+1][j+sum[r]-sum[l-1]], x);
			if (cnt1) Inc(dp[i+1][j-1+sum[r]-sum[l-1]], x);
		}
	}
	printf("%d\n", dp[n+1][0]);
}

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


Measured memory_bytes: 33920
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for a in range(a+1):
    for b in range(b+1):
        for c in range(c+1):
            if x == a*500 + b*100 + c*50:
                ans += 1
print(ans)

Measured memory_bytes: 39408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
double table5[7]={35.50,37.50,40.0,43.0,50.0,55.0,70};
double table1[7]={71.0,77.0,83.0,89.0,105.0,116.0,148.0};
string score[7]={"AAA","AA","A","B","C","D","E"};
int main(){
	double a,b;
	while(cin>>a>>b){
		int t5 = 100;
		int t1 = 100;
		for(int i =0;i < 7;i++){
			if(a<table5[i]){
				t5 = i;
				break;
			}
		}
		for(int j =0;j < 7;j++){
			if(b<table1[j]){
				t1 =j;
				break;
			}
		}
		int ans = max(t1,t5);
		if(ans==100){
			cout <<"NA"<<endl;
		}else{
			cout <<score[ans]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1224
x = input().split()
for i in range(len(x)):
  x[i] = int(x[i])
list = input().split()
for i in range(x[0]):
  list[i] = int(list[i])
list.sort()
sum = 0
for i in range(x[1]):
  sum += list[i]
print(sum)

Measured memory_bytes: 9192
a = (int)(input())
mons = list(map(int, input().split(" ")))
yuu = list(map(int, input().split(" ")))
count = 0
for i in range(a):
  if yuu[i] >= mons[i]:
    yuu[i] -= mons[i]
    count += mons[i]
    mons[i] = 0
    if yuu[i] >= mons[i + 1]:
      yuu[i] -= mons[i + 1]
      count += mons[i + 1]
      mons[i + 1] = 0
    else:
      mons[i + 1] -= yuu[i]
      count += yuu[i]
  else:
    mons[i] -= yuu[i]
    count += yuu[i]
    mons[i] -= yuu[i]
print(count)

Measured memory_bytes: 19004
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		boolean[] arr = new boolean[26];
		for (int i = 0; i < s.length(); i++) {
			int x = s.charAt(i) - 'a';
			if (arr[x]) {
				System.out.println("no");
				return;
			}
			arr[x] = true;
		}
		System.out.println("yes");
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, bitx[200001], bity[200001];

int minb(int bit[200001], int i) {
    int m = 1e9;
    while (i > 0) {
        m = min(m, bit[i]);
        i -= i & -i;
    }
    return m;
}

void update(int bit[200001], int i, int x) {
    while (i <= N) {
        bit[i] = min(bit[i], x);
        i += i & -i;
    }
}

int main() {
    int Q;
    cin >> N >> Q;
    REP(i, 200001) {
        bitx[i] = 1e9;
        bity[i] = 1e9;
    }
    update(bitx, 1, N);
    update(bity, 1, N);

    ll ans = (ll)(N - 2) * (N - 2);
    REP(i, Q) {
        int type, x;
        cin >> type >> x;

        if (type == 1) {
            int r = minb(bitx, N + 1 - x);
            ans -= r - 2;
            update(bity, N + 1 - r, x);
        } else {
            int r = minb(bity, N + 1 - x);
            ans -= r - 2;
            update(bitx, N + 1 - r, x);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5148
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	_ = sc.i()
	S := sc.s()

	fmt.Println(strings.Count(S, "ABC"))

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 640
#include <bits/stdc++.h>                                           
 
//#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb; 
typedef long long ll;  
typedef double db;                         
 
 
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = mp(1171, 3307), Mod = mp(1e9 + 7, 1e9 + 9);
const int inf = 1e9, N = 1e5 + 48, mod = 1e9 + 7, maxn = 102;
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


int n, k, a[maxn], dp[maxn][N], pr[maxn][N];


int get (int l, int r, int tp) { 
	return ((pr[tp][r] - pr[tp][l - 1]) % mod + mod) % mod;
}


void add (int &x, int y) {
	x += y;
	if (x >= mod)
		x -= mod;
	if (x < 0)
		x += mod;                       	
}


main () {
	cin >> n >> k;
	forn (i, 1, n)
		cin >> a[i];

	dp[0][0] = 1;
	forn (i, 0, k)
		pr[0][i] = 1;

	forn (i, 1, n)
		forn (j, 0, k) {
			dp[i][j] = get(max(0, j - a[i]), j, i - 1);  
			if (j)
				pr[i][j] = pr[i][j - 1];
			add(pr[i][j], dp[i][j]);		
		}

/*
	forn (i, 1, n) {
		forn (j, 0, k) 
			cout << dp[i][j] << ' ';
		cout << endl;
	}

	cout << endl << endl;
	forn (i, 1, n) {
		forn (j, 0, k) 
			cout << pr[i][j] << ' ';
		cout << endl;
	}*/


	cout << dp[n][k] << endl;			
}                       

Measured memory_bytes: 79616
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

const long long int inf=199999;
const long long int mod=1000000007;



long long int n,m,p;
//ベルマンフォード(ある一点からの最短経路)
const long long int INF = 99999999999999999;

struct edge {
	long long int from, to, cost;
};
edge ed[200101];
long long int d[201000];
long long int V, E,cou=0;

void Bellman_Ford(int s) {
	for (int i = 0; i < V; i++) { d[i] = INF; }
	d[s] = 0;
	
		bool finupdate =false;
	while (true) {
		bool update = false;
		
		for (int i = 0; i < E; i++) {
			edge e = ed[i];
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
				if(e.to==V-1&&cou>5000){
					finupdate=true;
				}
			}
		}
		cou++;
		if(cou>10005&&finupdate==true){cout<<-1;cou=INF;return;}
		
		if(cou>10005){cout<<max(-d[V-1],0LL);cou=INF;return;}
		if (!update) { break; }
	}
}

int main() {
    long long int count=0;
	
    map<long long int,long long int>mp;
	cout << fixed << setprecision(10);
    cin>>V>>E>>p;
	for(int i=0;i<E;i++){
		cin>>ed[i].from>>ed[i].to>>ed[i].cost;
		ed[i].from--;
		ed[i].to--;
		ed[i].cost=p-ed[i].cost;
	}
	Bellman_Ford(0);
	if(cou==INF){
		return 0;
	}
	cout<<max(-d[V-1],0LL);
} 


Measured memory_bytes: 384
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

int main(int argc, char const *argv[])
{
	int n,a,b;
	int f = 0,p = 0;
	char s[100003];

	scanf("%d%d%d",&n,&a,&b);
	scanf("%s",s);

	for(int i = 0; i < n; ++i){
		if(s[i] == 'a'){
			if(p < a + b){
				puts("Yes");
				++p;
			}
			else{
				puts("No");
			}
		}
		if(s[i] == 'b'){
			if(p < a + b && f < b){
				puts("Yes");
				++p;
				++f;
			}
			else	puts("No");
		}
		if(s[i] == 'c')	puts("No");
	}
	return 0;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

N, K, L = MAP()

tree_pq = UnionFind(N+1) # N点集合からUnionFind木を作成
tree_rs = UnionFind(N+1)
pq = [LIST() for _ in range(K)]
for p, q in pq:
	tree_pq.union(p, q) # p, qを同じグループに
group_pq = [tree_pq.find(i) for i in range(N+1)]
# print(group_pq)
rs = [LIST() for _ in range(L)]
for r, s in rs:
	tree_rs.union(r, s)
group_rs = [tree_rs.find(i) for i in range(N+1)]
# print(group_rs)

keys = []
dic = {}
pairs = [(group_pq[i], group_rs[i]) for i in range(N+1)]
for i in range(1, N+1):
	pair = (group_pq[i], group_rs[i])
	keys.append(pair)
	if pair in dic:
		dic[pair] += 1
	else:
		dic[pair] = 1

ans = [str(dic[key]) for key in keys]
print(" ".join(ans))

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

int main()
{
    int t=1;
    //cin>>t;
    
    while(t--)
    {
        char c;
        cin>>c;
        
        if(c>=65 && c<=90)
        {
            cout<<"A"<<endl;
        }
        else
        {
            cout<<"a"<<endl;
        }
    }    
    return 0;
}

Measured memory_bytes: 3616
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = null;
		while((str = br.readLine()) != null){
			String array[] = str.split(" ");
			int a = Integer.parseInt(array[0]);
			int b = Integer.parseInt(array[1]);
			int c = Integer.parseInt(array[2]);
			int baisuu = 1;
			while(true){
				if((a*baisuu)%b ==  c){
					System.out.println("YES");
					break;
				}else if((a*baisuu)%b ==  c || (a*baisuu)%b ==  0){
					System.out.println("NO");
					break;
				}
				baisuu++;
			}
		}
	}
}


Measured memory_bytes: 22484
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
string s;
cin>>s;
n=s.size();
ll ca=0;
ll cb=0;
for(ll i=0; i<n; i++){
if(s.at(i)=='1'){
ca++;}
else{
cb++;}}
cout<<min(ca,cb)*2<<endl;}


Measured memory_bytes: 3768
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	ll h, w, n, a, b;
	map<pair<ll, ll> , ll> mp;
	cin >> h >> w >> n;
	for(int i = 0;i < n;i++){
		cin >> a >> b;
		a--;
		b--;
		for(ll nowX = max(0LL, b - 2);nowX <= b;nowX++){
			for(ll nowY = max(0LL, a - 2);nowY <= a;nowY++){
				mp[make_pair(nowX, nowY)]++;
			}
		}
	}

	map<pair<ll, ll>, ll>::iterator it = mp.begin();
	ll ans[10] = {};
	while(it != mp.end()){
		int now = (*it).second;
		pair<ll, ll> xy = (*it).first;
		if(xy.first >= w - 2 || xy.second >= h - 2) {
			it++;
			continue;
		}
		ans[now]++;
		it++;
	}

	ll sum = 0;
	for(int i = 0;i < 10;i++){
		sum += ans[i];
	}

	ll zero = (w - 2) * (h - 2);
	cout << zero - sum << endl;
	for(int i = 1;i < 10;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 56448
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int y = 0;
    string x;
    cin>>x;
    for(int i = 0;i<x.size();i++){
        if(x.at(i) == '9'){
            cout<<"Yes"<<endl;
            y = 1;
            break;
        } 
    }
    if(y == 0) cout<<"No"<<endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int l=s.length();
	for(int i=0;i<l-1;i++)
	{
		if(s[i]=='A'&&s[i+1]=='C')
		{
			printf("Yes\n");
            return 0;
		}
	}
    printf("No\n");
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 998244353;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

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

  ll turn = 0;

  while (a > 0 && c > 0) {

    if (turn == 0) {
      c -= b;
    } else {
      a -= d;
    }
    turn ^= 1;
  }

  if (c <= 0) {
    cout << "Yes";
  } else
    cout << "No";

  return 0;
}


Measured memory_bytes: 3636