akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::io::{stdin, Read, StdinLock};
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::{HashSet, HashMap, BinaryHeap};
#[allow(unused_imports)]
use std::vec::Vec;

#[allow(dead_code)]
const INF: i32 = 1000_000_000;
#[allow(dead_code)]
const INFLL: i64 = 1000_000_000_000_000_000;
#[allow(dead_code)]
const EPS: f64 = 1.0e-10;
#[allow(dead_code)]
const MOD: i32 = 1000_000_007;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    #[allow(dead_code)]
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner {cin: cin}
    }

    #[allow(dead_code)]
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
                    .skip_while(|c| c.is_whitespace())
                    .take_while(|c| !c.is_whitespace())
                    .collect::<String>();
        token.parse::<T>().ok()
    }

    #[allow(dead_code)]
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


trait Group {
    /// Data type
    type T: Clone;

    /// Identity function
    fn id() -> Self::T;

    /// Operator: op(a, b) <-> ab in this order
    fn op(a: &Self::T, b: &Self::T) -> Self::T;

    /// Inverse
    fn inverse(a: &Self::T) -> Self::T;
}

struct FenwickTree<G: Group> {
    data: std::vec::Vec<G::T>,
    size: usize
}

#[allow(dead_code)]
impl<G: Group> FenwickTree<G> {
    fn new(n: usize) -> FenwickTree<G> {
        FenwickTree::<G> {
            data: vec![G::id(); n],
            size: n,
        }
    }

    fn operate(&mut self, mut i: usize, val: G::T) {
        while i < self.size {
            self.data[i] = G::op(&self.data[i], &val);
            i |= i + 1;
        }
    }

    /// [0..r]
    fn query1(&self, mut r: i32) -> G::T {
        let mut res = G::id();
        while r >= 0 {
            res = G::op(&res, &self.data[r as usize]);
            r = (r & (r + 1)) - 1;
        }
        res
    }
    /// [l..r)
    fn query(&self, l: i32, r: i32) -> G::T {
        G::op(&self.query1(r - 1), &G::inverse(&self.query1(l - 1)))
    }
}

/// Example: Range Sum
struct RangeSum;
#[allow(dead_code)]
impl Group for RangeSum {
    type T = i32;
    fn id() -> i32 {
        0
    }
    fn op(a: &i32, b: &i32) -> i32 {
        a + b
    }
    fn inverse(a: &i32) -> i32 {
        -a
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let n: usize = sc.read();
    let q: usize = sc.read();
    let mut bit: FenwickTree<RangeSum> = FenwickTree::new(n);
    for _i in 0..q {
        let com: usize = sc.read();
        let x: i32 = sc.read();
        let y: i32 = sc.read();
        match com {
            0 => bit.operate((x - 1) as usize, y),
            1 => println!("{}", bit.query(x - 1, y)),
            _ => panic!("Invalid Command")
        }
    }
}


Measured memory_bytes: 5052
#ifndef ___Class_BIT
#define ___Class_BIT

// ------ Includes ------ //
#include <vector>
#pragma warning(disable : 4146)

// ------ Class ------ //
template <typename Type>
class BIT {
private:
	unsigned size_; std::vector<Type> v;
	Type sum(unsigned r) {
		Type ret = 0;
		while (r > 0) {
			ret += v[r];
			r -= r & (-r);
		}
		return ret;
	}
public:
	BIT() {};
	BIT(unsigned size__) {
		for (size_ = 1; size_ < size__;) size_ <<= 1;
		v.resize(size_ + 1, 0);
	}
	inline void add(unsigned i, Type x) {
		i++;
		while (i <= size_) {
			v[i] += x;
			i += i & -i;
		}
	}
	inline Type sum(unsigned l, unsigned r) {
		return sum(r) - sum(l);
	}
	bool operator[](unsigned x) {
		return sum(x, x + 1);
	}
};

#endif

#include <cstdio>
#pragma warning(disable : 4996)

int n, q, c, x, y;
int main() {
	scanf("%d%d", &n, &q);
	BIT<int> Q(n);
	while (q--) {
		scanf("%d%d%d", &c, &x, &y);
		if (c == 0) Q.add(x - 1, y);
		else printf("%d\n", Q.sum(x - 1, y));
	}
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin.exceptions(cin.failbit);
     
    string s;
    cin >> s;
    bool a = false; bool b = false;
    for (int i=0;i<s.length();i++)
    {
    	if (s[i]=='A') a = true;
    	if (s[i]=='B') b = true;
    }
	if (a & b) cout << "Yes\n";
	else cout << "No\n";	
	return 0;
}
	

Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
  var N = one[0];
  var d = one[1];
  if(N <= 2){
    myout(0);
    return;
  }
  N -= 3;
  var loop = Math.floor(N / 11);
  var amari = N % 11;
  var map = {
  	0 : [1,1,1,2,2,3,4,4,5,5,5],
    1 : [0,1,2,2,3,3,3,4,4,4,5],
    2 : [1,1,1,2,2,2,3,3,4,5,5],
    3 : [0,0,1,1,2,3,3,4,4,4,5],
    4 : [1,2,2,3,3,3,4,4,4,5,5],
    5 : [0,0,1,1,1,2,2,3,4,4,5],
    6 : [0,1,1,2,3,3,4,4,4,5,5],
    7 : [1,1,2,2,2,3,3,3,4,4,5],
    8 : [0,1,1,1,2,2,3,4,4,5,5],
    9 : [1,1,2,3,3,4,4,4,5,5,5],
    10 : [0,1,1,1,2,2,2,3,3,4,5]
  };
  myout(loop * 5 + map[d][amari]);
}


Measured memory_bytes: 30108
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();
		if (X == 3 || X == 5 || X == 7) System.out.print("YES");
		else System.out.print("NO");
	}
}

Measured memory_bytes: 23124
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	static class Node {
		int value;
		Node next;
	}

	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		ArrayList<Integer>[] edge = new ArrayList[N];
		for (int i = 0; i < M; i++) {
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;
			append(edge, a, b);
		}
		int min = Integer.MAX_VALUE;
		int start = 0;
		for (int i = 0; i < N; i++) {
			int m = minLoop(i, edge);
			// System.out.println("min = " + m);
			if (m < min) {
				min = m;
				start = i;
			}
		}
		if (min == Integer.MAX_VALUE) {
			System.out.println(-1);
			return;
		}
		int[] prev = new int[N];
		Arrays.fill(prev, -1);
		Queue<Integer> q = new ArrayDeque<>();
		q.add(start);
		while (q.size() > 0 && prev[start] == -1) {
			int val = q.poll();
			if (edge[val] != null) {
				for (int next : edge[val]) {
					if (prev[next] == -1) {
						prev[next] = val;
						q.add(next);
					}
				}
			}
		}
		// System.out.println("start = " + start);
		// printArray(prev);
		int pos = start;
		int[] routes = new int[min];
		for (int i = min - 1; i >= 0; i--) {
			int p = prev[pos];
			routes[i] = p;
			pos = p;
		}
		System.out.println(min);
		for (int x : routes) {
			System.out.println(x + 1);
		}
	}

	static int minLoop(int start, ArrayList<Integer>[] edge) {
		int[] depth = new int[edge.length];
		depth[start] = 1;
		Queue<Integer> q = new ArrayDeque<>();
		q.add(start);
		while (q.size() > 0) {
			int val = q.poll();
			if (edge[val] != null) {
				int d2 = depth[val] + 1;
				for (int next : edge[val]) {
					if (next == start) {
						return d2 - 1;
					}
					if (depth[next] == 0) {
						depth[next] = d2;
						q.add(next);	
					}
				}
			}
		}
		return Integer.MAX_VALUE;
	}

	static void append(ArrayList<Integer>[] edge, int a, int b) {
		if (edge[a] == null) {
			edge[a] = new ArrayList<>();
		}
		edge[a].add(b);
	}
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const ll mod = 1e9+7;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}
  vector<int> a,b;

ll v[10002];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h,n;
  cin >> h >> n;
  a.resize(n), b.resize(n);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  rep(i, h + 1){
      if(i == h){
        v[i] = 0;
      }
      else
      v[i] = inf; 
  }
  for(int i = h; i > 0; --i){
    rep(j, n){
      ll I = i, u;
        u = I;
        I -= a[j];
        I = I < 0 ? 0 : I;
        v[I] = min(v[I], v[u] + b[j]);
    }
  }
  ll ans = inf;
  rep(j,n){
    ans = std::min(v[0],ans); 
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int N;
  string S, T;
  cin >> N >> S >> T;
  if (N==1) {
    cout << S.at(0) << T.at(0) << endl;
  }
  else {
    for (int i=0; i<N-1; i++) {
      cout << S.at(i) << T.at(i);
    }
    cout << S.at(N-1) << T.at(N-1) << endl;
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	string s;
	cin >> s;
	cout << s[0] << s[1] << s[2];
}


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

int k;

void solve(){
    cin >> k;
    if(k%7==0){
        k/=7;
    }
    if(k%2==0 || k%5==0){
        cout << -1 << endl;
        return;
    }
    int s=1,t=1;int ans=1;
    while(s%k!=0){
        t*=10;
        t%=k;
        s+=t;
        s%=k;
        ans+=1;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<ll> as(n);
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    as[a]++;
    as[b]++;
  }

  rep(i, n) cout << as[i] << endl;

  return 0;
}


Measured memory_bytes: 3540
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  vector<int> a(26, 0);
  for (int i = 0; i < s.size(); i++) {
    int b = s[i] - 'a';
    if (a[b]) {
      cout << "no" << endl;
      return 0;
    } else {
      a[b]++;
    }
  }
  cout << "yes" << endl;
  return 0;
}

Measured memory_bytes: 256
while 1:
    N = input()
    if N == "0":
        break
    dp = [[0 for i in range(11)] for j in range(len(N) + 1)]
    for i, c in enumerate(N, 1):
        for j, kazu in enumerate(dp[i - 1]):
            if kazu != 0:
                dp[i][(j * 10 + int(c)) % 11] = kazu
        if int(c) != 0:
            dp[i][int(c) % 11] += 1
    ans = 0
    for d in dp:
        ans += d[0]
    print(ans)
  
        


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

#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


string s;
int transition[10][10101], n, p;
ll ans;
int dp[2][10101];
ll modpow(ll x, ll y)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

int32_t main()
{
    usecppio
    cin >> n >> p >> s;
    int inv = modpow(10, p-2);
    if (p < 10)
    {
        for (int j = 0; j<10; j++)
            for (int i = 0; i<p; i++)
                transition[j][i] = ((i*10)+j)%p;
        int r = 0;
        for (int i = 0; i<n; i++)
        {
            int u = s[i]-'0';
            r = 1-r;
            memset(dp[r],0,sizeof(dp[r]));
            for (int j = 0; j<p; j++)
            {
                int k = transition[u][j];
                dp[r][k] += dp[1-r][j];
            }
            dp[r][transition[u][0]]++;
            ans += dp[r][0];
        }
        cout << ans << '\n';
    }
    else
    {
        for (int j = 0; j<10; j++)
            for (int i = 0; i<p; i++)
                transition[j][i] = (((i-j+p)%p)*(inv))%p;
        int r = 0;
        for (int i = 0; i<n; i++)
        {
            register int u = s[i]-'0';
            r = 1-r;
            for (int j = 0; j<p; j++)
            {
                int k = transition[u][j];
                dp[r][j] = dp[1-r][k];
            }
            dp[r][u]++;
            ans += dp[r][0];
        }
        cout << ans << '\n';
    }
}


Measured memory_bytes: 1044
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <tuple>
#include <climits>
#include <sstream>
using namespace std;

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

    vector<int> v, c;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }

    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        c.push_back(tmp);
    }

    int res = 0;
    for (int i = 0; i < n; i++)
    {
        if (c[i] < v[i])
        {
            res += v[i] - c[i];
        }
    }

    cout << res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, P;
    cin >> N >> P;
    vector<vector<ll>> dp(N+1,vector<ll>(2));
    dp[0][0] = 1;
    REP(i,N){
        int a; cin >> a;
        REP(j,2) dp[i+1][j] = dp[i][j];
        REP(j,2) dp[i+1][(j+a)%2] += dp[i][j];
    }

    OUT(dp[N][P])

    return 0;
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
  ll n , k;
  cin >> n >> k;
  ll a = n % k;
  ll ans = (a < k -a) ? a : k - a;
  cout << ans << endl;

}


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


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

	int n, W;
	cin >> n >> W;
	vector<int> w(n), v(n);


	for (int i = 0; i < n; ++i) 
		cin >> w[i] >> v[i];


	const int mxv = (int) 1e5 + 10;


	vector<vector<ll>> dp(n, vector<ll>(mxv + 1, (ll) 1e18));

	dp[0][0] = 0;
	dp[0][v[0]] = w[0];

	for (int i = 1; i < n; ++i) {
		for (int j = 0; j <= mxv; ++j) {
			dp[i][j] = dp[i - 1][j];
			if (j - v[i] >= 0) {
				dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
			}
		}
	}


/* 	cout << "dp:\n"; */
/* 	for (int i = 0; i <= mxv; ++i) */ 
/* 		cout << setw(3) << i << " "; */
/* 	cout << endl; */
/* 	for (int i = 0; i < n; ++i) { */
/* 		for (int j = 0; j <= mxv; ++j) { */
/* 			cout << setw(3) << dp[i][j] << " "; */
/* 		} */
/* 		cout << endl; */
/* 	} */
/* 	cout << endl; */

	ll ans = 0;

	for (ll i = 0; i <= mxv; ++i) 
		if (dp[n - 1][i] <= W) 
			ans = max(ans, i);

	cout << ans << "\n";

}



Measured memory_bytes: 79616
//

#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
	int A[3];
	cin >> A[0] >> A[1] >> A[2];

	sort(A, A+3);
	cout << (A[2]-A[1]) + (A[1]-A[0]) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
  int A, B, K;
  cin >> A >> B >> K;
  int mod0cnt = 0;
  for (int i = min(A, B); i > 0; i--) {
    if ((A%i==0) && (B%i==0)) {
      mod0cnt++;
      if (mod0cnt==K) {
        cout << i << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

int main(){
	string s; cin >> s;
	int a = -1, z = -1;
	for(int i = 0; i < s.size(); ++i){
		if(s[i] == 'A' && a == -1) a = i;
		if(s[s.size() - 1 - i] == 'Z' && z == -1) z = s.size() - 1 - i;
		if(a >= 0 && z >= 0) break;
	}
	cout << z - a + 1 << endl;
	return 0;
}

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

int A[100105];

int main(){
	int n,m,k;
	cin >> n >> m;
	vector<int> v(m),v2(m);
	for(int i=0;i<m;i++){
		cin >> v[i] >> v2[i];
		v[i]--, v2[i]--;
	}
	
	set<int> se;
	vector<int> v3(n);
	
	int pos=0;
	A[0]=A[1]=1;
	for(int i=0;i<m;i++){
		if(pos==v[i])
			pos = v2[i];
		else if(pos == v2[i])
			pos = v[i];
		
		swap(A[v[i]], A[v2[i]]);
		if(pos-1 >= 0)
			A[pos-1] = 1;
		if(pos+1 < n){
			A[pos+1] = 1;
		}
	}
	
	int ans=0;
	for(int i=0;i<n;i++){
		if(A[i])
			ans++;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;

class MyClass
{
    static void Main(string[] args)
    {
        string[] str = Console.ReadLine().Split(' ');
        int n = int.Parse(str[0]);
        int m = int.Parse(str[1]);
        int[] a = new int[m];
        int[] b = new int[m];
        int person = 0;
        bool impossible = false;
        for (int i = 0; i < m; i++)
        {
            str = Console.ReadLine().Split(' ');
            a[i] = int.Parse(str[0]);
            b[i] = int.Parse(str[1]);
        }
        int left = 1;
        int right = n;
        do
        {
            int maxb = 0;
            int maxb_i = -1;
            int mina = n;
            int mina_i = -1;
            for (int i = 0; i < m; i++)
            {
                if (a[i] <= left && left <= b[i])
                {
                    if (maxb <= b[i])
                    {
                        maxb = b[i];
                        maxb_i = i;
                    }
                }
                if (a[i] <= right && right <= b[i])
                {
                    if (mina >= a[i])
                    {
                        mina = a[i];
                        mina_i = i;
                    }
                }
            }
            if (maxb_i == -1 || mina_i == -1)
            {
                Console.WriteLine("Impossible");
                impossible = true;
                break;
            }
            if (maxb_i == mina_i || (a[mina_i] <= left && right <= b[mina_i]) || (a[maxb_i] <= left && right <= b[maxb_i]))
            {
                person += 1;
            }
            else
            {
                person += 2;
            }
            left = maxb + 1;
            right = mina - 1;
        } while (left <= right);
        if (!impossible)
        {
            Console.WriteLine(person);
        }
    }
}


Measured memory_bytes: 19936
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
using namespace std;
#define _GLIBCXX_DEBUG
typedef long long ll;
const ll mod=1000000007;
ll pow(ll x,ll y){
  ll res=1;
  for(ll i=0;i<y;i++){
    res*=x;
  }
  return res;
}

ll powmod(ll x,ll y){
  ll res=1;
  for(ll i=0;i<y;i++){
    res=res*x%mod;
  }
  return res;
}
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

main(){
  int n,m;cin >> n >> m;
  UnionFind uf(n);
  for(int i=0;i<m;i++){
    int a,b;cin >> a >> b;
    a--;b--;
    uf.unite(a,b);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,uf.size(i));
  }
  cout << ans << endl;
  return 0;

}

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

int main(){

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

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

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

    for(int i = 0;i < n-1;i ++){
        if(a.at(i) == a.at(i+1)){
            a.at(i) = 0;
            a.at(i+1) = 0;
        }
    }

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

    while(a.at(a.size()-1) == 0){
        a.pop_back();
        if(a.size() == 0){
            break;
        }
    }

    cout << a.size() << endl;
}

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

const ll mod = 1e9+7;

int main(){
  ll N; cin >> N;
  vector<ll> A(N); for(ll i = 0; i < N; i++){ cin >> A[i];}
  
  ll r = 0; ll g = 0; ll b = 0;
  
  ll ans = 1LL;
  
  for(ll i = 0; i < N; i++){ 
    // 同じものが複数ある時は、r,g,bの順で選ぶ つまり常に r <= g <= bとして構わない。
    ll a = A[i]; int color = 0; ll cnt = 0;
    
    if( a == b){ color = 3; cnt++;}
    if( a == g){ color = 2; cnt++;}
    if( a == r){ color = 1; cnt++;}
    bool ok = false;
    if( color == 1){ r++; ok = true;}
    if( color == 2){ g++; ok = true;}
    if( color == 3){ b++; ok = true;}
    
    if(!ok){ cnt = 0;}
    
   
    
    ans *= cnt;
    ans %= mod;
  }
  
  cout << ans << endl;
  
  return 0;
}
    
   


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

int main() {
    long long int n, k, rem, num, c = 0;
    cin>>n>>k;
    num = n;
    if (k == 10)
    {
        while(num != 0)
        {
            c++;
            num = num / 10;
        }
        cout<<c;
    }
    else
    {
        while (num != 0)
        {
            rem = num % k;
            c++;
            num = num / k;
        }
        cout<<(c);
    }
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
  
  int a,b,c,k,ma=0;
  cin>>a>>b>>c>>k;
  if(a>=b&&a>=c)
    a*=pow(2,k);
  if(b>=a&&b>=c)
    b*=pow(2,k);
  if(c>=a&&c>=b)
    c*=pow(2,k);
  cout<<a+b+c<<endl;
}

Measured memory_bytes: 4016
n,y=map(int,input().split())
for i in range(n+1):
    for j in range(n+1):
        z=n-i-j
        if 0<=z:
            if 10000*i+5000*j+1000*z==y:
                print(i,j,z)
                exit()
print(-1,-1,-1)
exit()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define loop(x) for(int i=0;i<x;i++)
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra

// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }
  int n,m;
   vector<int>v[100002];
   int dp[100003];
int solve(int st){
  if(dp[st]!=-1)
    return dp[st];
  int ans=0;
  for(int i=0;i<v[st].size();i++){
    ans=max(ans,1+solve(v[st][i]));
  }
  return dp[st]=ans;
}
int main(){
    IOS;
   
    cin>>n>>m;
    int x,y;
   memset(dp,-1,sizeof dp);
    loop(m){
      cin>>x>>y;
      v[x].pb(y);
    }
    int ans=0;
    for(int i=1;i<=n;i++){
      ans=max(ans,solve(i));
    }
    cout<<ans<<endl;
}
// https://atcoder.jp/contests/dp/tasks/dp_d
// https://codeforces.com/contest/1131/problem/C
 


Measured memory_bytes: 8192
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int a; string s;
	cin>>a;
	cin>>s;
	if(a >= 3200){
		cout<<s<<endl;
	}else{
		cout<<"red"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define MAX 2000000

int size, a[MAX+1];

void maxHeapify(int i){

  int l,r,large,t;
  
  l = 2*i;

  r = 2*i+1;

  if((l <= size) && (a[l] > a[i])){
    large = l;
  }
  
  else{
    large = i;
  }
  
  if((r <= size) && (a[r] > a[large])){
    large = r;
  }
  
  if(large != i){
    t = a[i];
    a[i] = a[large];
    a[large] = t;
    
    maxHeapify(large);
    
  }
  
}

int extract(){

  int maxv;

  if(size < 1){
    return;
  }
  
  maxv = a[1];
  
  a[1] = a[size--];
  
  maxHeapify(1);

  return maxv;

}

void increaseKey(int i, int key){

  int x;

  if(key < a[i]){
    return;
  }
  
  a[i] = key;
  
  while((i > 1) && (a[i/2] < a[i])){

    x = a[i];
    a[i] = a[i/2];
    a[i/2] = x;
    
    i = i/2;

  }
}

void insert(int key){

  size++;
  a[size] = -1000000001;

  increaseKey(size,key);
  
}

int main(){

  int key;
  char c[20];

  while(1){

    scanf("%s",c);
    if(c[0] == 'i'){

      scanf("%d",&key);
      

      insert(key);
    }

    else if(strcmp(c,"extract") == 0){
      printf("%d\n",extract());
    }

    else{
      break;
    }
    
  }

  return 0;

}



Measured memory_bytes: 5652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double N,T,A,c,m,d;
  cin >> N >> T >> A;
  vector<double> H(N);
  for(double i=0;i<N;i++){cin >> H[i];}
  m=abs(T-H[0]*0.006-A);
  for(double i=0;i<N;i++){
    c=abs(T-H[i]*0.006-A);
    if(m>c){m=c; d=i;}
  }
  cout << d+1 << endl;
}

Measured memory_bytes: 256
s = input()
List = list(s)+['R']
n=len(List)
R = 0
L = 0
ans = [0]*n
for i in range(n):
  if List[i]=='R':
    R += 1
    if L > 0:
      ans[i-L] += (L+1)//2
      ans[i-L-1] += L//2
      L = 0
  else:
    L += 1
    if R > 0:
      ans[i] +=R//2
      ans[i-1] += (R+1) //2
      R = 0
print(*ans[:-1])

Measured memory_bytes: 12316
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
long long int comb(long long int n,long long int r){
    vector<vector<long long int> > v(n+1,vector<long long int>(n+1,0));
    long long int i,j;
    rep(i,0,n+1){
        v.at(i).at(0)=1;
        v.at(i).at(i)=1;
    }
    rep(i,0,n+1){
        rep(j,0,i)v.at(i).at(j)=v.at(i-1).at(j-1)+v.at(i-1).at(j);
    }
    return v.at(n).at(r);
}
int main(void){
    int N,M,i,O=0,X=0;
    cin>>N>>M;
    vector<int> p(M),o(N),x(N);
    vector<string> S(M);
    rep(i,0,M)cin>>p.at(i)>>S.at(i);
    rep(i,0,M){
        if(o.at(p.at(i)-1)==0){
            if(S.at(i)=="WA")x.at(p.at(i)-1)++;
            else o.at(p.at(i)-1)++;
        }
    }
    rep(i,0,M)if(o.at(p.at(i)-1)==0)x.at(p.at(i)-1)=0;
    rep(i,0,N){
        O+=o.at(i);
        X+=x.at(i);
    }
    cout<<O<<" "<<X<<endl;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
template<typename T> T gcd(T a,T b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 100009;
int n, m, p[N];
vi v[N];
bool s[N], s2[N], f[N];
vi s3;
void search(int a){
  s[a] = true;
  s2[a] = true;
  s3.pb(p[a]-1);
  each(itr, v[a]){
    if(s2[*itr]) continue;
    search(*itr);
  }
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n) cin >> p[i];
  FOR(i, 0, m){
    int x, y;
    cin >> x >> y;
    x--; y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  int ans = 0;
  FOR(i, 0, n){
    if(s[i]) continue;
    search(i);
    each(itr, s3) if(s2[*itr]) ans++;
    memmove(s2, f, sizeof(f));
    s3.clear();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9980
a = list(map(int, input().split()))
if (a[1] == 0):
    print(0)
else:
    if a[0] - int(a[0] / (a[1] + a[2])) * (a[1] + a[2]) > a[1]:
        print(int(a[0] / (a[1] + a[2])) * a[1] + a[1])
    else:
        print(int(a[0]/(a[1]+a[2]))*a[1]+a[0] -
              int(a[0] / (a[1] + a[2])) * (a[1] + a[2]))

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	string s;
	cin >> s;
	vector<int> a(4);
	rep(i,4) a[i] = s[i] - '0';

	for(int tmp = 0; tmp < (1 << 3); tmp++){
		int num = a[0];
		bitset<3> bit(tmp);
		rep(i,3){
			if(bit.test(i)){
				num += a[i+1];
			} else {
				num -= a[i+1];
			}
		}
		if(num == 7){
			cout << a[0];
			rep(i,3){
				if(bit.test(i)){
					cout << "+";
				} else {
					cout << "-";
				}
				cout << a[i+1];
			}
			cout <<  "=7" << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 256
while line = gets
	num = line.split(" ")
	n,x = num[0].to_i,num[1].to_i
	break if n == 0 && x == 0
	ans = 0
	r = (1..n)
	r.each{|i|
		r.each{|j|
			next if i == j
			r.each{|k|
				next if j == k || i == k
				ans += 1 if i + j + k == x
			}
		}
	}
	p ans / 6
end

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

int main(){
  
  int N=0;
  scanf("%d",&N);

  for(int i=8; i>=0; i--){
    if(N >= pow(2,i)){
      printf("%d",(int)pow(2,i));
      return 0;
    }
  }

  return 0;

}

Measured memory_bytes: 128
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,child,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int h[100];
int main(){
  int a, b;
  cin >> a >> b;
  cout << (a * b / 2) << endl;
  return 0;
}


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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int S;
  cin >> S;
  const int mod = 1e9 + 7;

  vector<ll> dp(S + 1);
  dp[0] = 1;
  for (int i = 3; i <= S; i++) {
    for (int j = 3; j <= i; j++)
      dp[i] = (dp[i] + dp[i-j]) % mod;
  }

  cout << dp[S];
}

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

  // int t;
  // cin >> t;
  // while (t--) {
    solve();
    cout << nl;
  // }

  return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;

int main() {
  string s;
  int k, n;
  cin >> s >> k;
  n = s.size();
  for(int i = 0; i < n; i++) {
    if('z' - s[i] + 1 <= k && s[i] > 'a') {
      k -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
  k %= 26;
  s[n - 1] = (s[n - 1] - 'a' + k) % 26 + 'a';
  cout << s << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cnt[200001];
int main(void){
    int n,i,max=0;
    char s[200001][11];
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%s",s[i]);
    qsort(s,n,11,strcmp);
    cnt[0]=1;
    for(i=1;i<n;i++){
        if(strcmp(s[i-1],s[i])==0){
            cnt[i]=cnt[i-1]+1;
        }
        else{
            cnt[i]=1;
            if(max<cnt[i-1]) max=cnt[i-1];
        }
    }
    if(max<cnt[n-1]) max=cnt[n-1];
    for(i=0;i<n;i++){
        if(cnt[i]==max) printf("%s\n",s[i]);
    }
    return 0;
}


Measured memory_bytes: 4884
N=int(input())
A=list(map(int, input().split()))
cent=sum(A)/N
if abs(cent-int(cent))>=0.5:
  if cent<0:
    cent=int(cent)-1
  else:
    cent=int(cent)+1
else:
  cent=int(cent)
ans=0
for a in A:
  ans+=(a-cent)**2
print(ans)

Measured memory_bytes: 9076
#include <iostream>
#include <cstring>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, x, y;
    cin >> n >> x >> y;
    int res[n];
    memset(res, 0, sizeof(res));
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            res[min(j - i, abs(j - y) + abs(i - x) + 1)]++;
        }
    }
    for (int i = 1; i < n; i++) cout << res[i] << "\n";
    return 0;
}

Measured memory_bytes: 384
def resolve():
    N, M, X, Y = list(map(int, input().split()))
    XN = list(map(int, input().split()))+[X]
    YM = list(map(int, input().split()))+[Y]
    xright = sorted(XN)[-1]
    yleft = sorted(YM)[0]
    print("No War" if xright < yleft else "War")


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 9048
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
ll height(ll h){
	return (3*h*(h-1))/2 + 2*h;
}
 
void solve()
{
  string s ,t ; 
  cin>>s>>t ;
  string temp =""; 
  rep(i  ,s.length()) temp += t[i] ;
  if(temp==s){
  	cout<<"Yes\n";

  }
  else{
  	cout<<"No\n";
  }

}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;

#define MOD 1000000007

int main()
{
	int n,m;
	cin >> n >> m;
	vector<long long> s(n),t(m);
	for(int i=0;i<n;i++)
		cin >> s[i];
	for(int i=0;i<m;i++)
		cin >> t[i];

	
	vector<vector<long long> > dp(n+1,vector<long long>(m+1,0));

	for(int i=0;i<=n;i++)
		dp[i][0]=1;
	for(int i=0;i<=m;i++)
		dp[0][i]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j]+dp[i][j-1];
			else
			{
				dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+MOD;
			}
			dp[i][j]%=MOD;
		}
	}
/*
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
			cout << dp[i][j] << " ";
		cout << endl;
	}
*/

	cout << dp[n][m] << endl;


	
}

Measured memory_bytes: 31616
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define rall(n) std::rbegin(n), std::rend(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N, W; std::cin >> N >> W;
	std::vector<Int> w(N), v(N);
	rep(i, N)std::cin >> w[i] >> v[i];

	std::vector<std::vector<Int>> dp(N + 1, std::vector<Int>(W + 1, -INF));
	rep(i, W + 1)dp[0][i] = 0;


	rep(i, N) {
		Int nw = w[i], nv = v[i];
		rep(j, W + 1) {
			if (j + nw <= W) {
				dp[i + 1][j + nw] = std::max(dp[i + 1][j + nw], dp[i][j] + nv);
			}
			dp[i + 1][j] = std::max(dp[i + 1][j], dp[i][j]);
		}
	}



	std::cout << dp[N][W];

}


int main() {

	init();
	calc();

	return 0;
}

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

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

  int n = s.size() + 1;
  vector<int> a(n);
  rep(i,n - 1){
  	if(s[i] == '<'){
  		a[i+1] = max(a[i+1], a[i] + 1);
  	}
  }

  for(int i = n - 2; i >= 0; --i){
  	if(s[i] == '>'){
  		a[i] = max(a[i], a[i+1] + 1);
  	}
  }

  ll ans = 0;
  for(ll s : a) ans += s;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2820
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ k, s ] <- readInts
	let	
		nums = [ 0 .. k ]
	print $ length $ filter ( \x -> 0 <= x && x <= k ) $ map ( s - ) $ (+) <$> nums <*> nums


Measured memory_bytes: 636
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
using namespace std;

int N, M;

int main() {
    cin >> N >> M;
    vector<int> a(M), v(M);
    int b, c;
    for (int i = 0; i < M; i++) {
        cin >> a[i] >> b;
        for (int j = 0; j < b; j++) {
            cin >> c;
            v[i] += 1 << (c - 1);
        }
    }
    int inf = 1e9;
    vector<int> cost(1 << N, inf);
    cost[0] = 0;
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 1 << N; j++) {
            if (cost[j] < inf) {
                b = j | v[i];
                cost[b] = min(cost[b], cost[j] + a[i]);
            }
        }
    }
    cout << (cost[(1 << N) - 1] < inf? cost[(1 << N) - 1] : -1) << endl;
}


Measured memory_bytes: 256