akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define EM 1000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
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; }

int main(){
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<char>    t(Q), d(Q);
    map<char, int>  LR;
    LR['R'] = 1, LR['L'] = -1;
    for(int i = 0;i < Q;i++)    cin >> t[i] >> d[i];
    int ans = N;
    for(int k = 0; k < 2;k++) {
        int l = -1, r = N;
        while (r > l + 1) {
            int mid = (l + r) / 2, m = mid;
            bool f = false;
            for (int i = 0; i < Q; i++) {
                if (m < 0 || m > N - 1) break;
                if (s[m] == t[i]) m += LR[d[i]];
                if ((k == 0 && m == N) || (k == 1 && m == -1)) f = true;
            }
            if(k == 0){
                if(f)   r = mid;
                else    l = mid;
            }else{
                if(f)   l = mid;
                else    r = mid;
            }
        }
        if(k == 0)  ans -= N-r;
        else    ans -= l+1;
    }
    cout << ans << endl;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  char c[H+1][W+1];
  for (int i = 0;i<H;i++) {
    cin >> c[i];
  }
  bool ok = true;
  for (int i = 0;i < H;i++) {
    for (int j = 0;j < W; j++) {
      if (c[i][j] == '#') {
        if ((c[i+1][j] != '#') && (c[i-1][j] != '#') && (c[i][j+1] != '#') && (c[i][j-1] != '#')) {
          ok = false;
        }
      }
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}
        
      
  
  



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include <algorithm>
using namespace std;
 
int main(){
  int N;
  int X;
  int L[110];
  
  cin >> N >> X;
  for(int i=0;i<N;++i) cin >> L[i];
  
  int counter = 1;
  int total = 0;
  for(int i=0;i<N;++i){
    total += L[i];
    if(total<=X) ++counter;
  }
  cout << counter << endl;
}

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

int main(void){
	long n;
	int flag=0;
	while(scanf(" %ld", &n) != EOF){
		int i, j, a[5];
		char c[5][7];
		
		if(flag==1) printf("\n");		
		
		for(i=0; i<5; i++)
			a[i] = (n/(int)pow(10, 4-i)) % 10;
	
		for(i=0; i<5; i++){
			for(j=0; j<7; j++){
				c[i][j] = '*';
			}
		}
		
		for(i=0; i<5; i++){
			c[i][(a[i]/5>0)?0:1] = ' ';
			c[i][2+a[i]%5] = ' ';
		}
		
		for(i=0; i<7; i++){
			if(i==2) printf("=====\n");
		
			for(j=0; j<5; j++){
				printf("%c", c[j][i]);
			}
			printf("\n");
		}
		
		flag=1;
	}

	return 0;
}

Measured memory_bytes: 632
/*

*/

#include<stdio.h>

int main() {
	int a, b, ans;
	scanf("%d %d", &a, &b);
	if(a<=b){
		ans = a;
	}
	else if (a>b){
		ans = a-1;
	}
	printf("%d\n", ans);
	//getch();
	return 0;
}

Measured memory_bytes: 128
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let m: u32 = sc.read();
    let k: u32 = sc.read();
    if m == 0 && k == 0 {
        println!("0 0");
        return;
    }
    if m == 1 {
        if k == 0 {
            println!("0 0 1 1");
            return ;
        }
        println!("-1");
        return;
    }
    let max_value = 2u32.pow(m);
    if max_value <= k {
        println!("-1");
        return;
    }
    for i in 0..max_value {
        if i == k {
            continue;
        }
        print!("{} ", i);
    }
    print!("{} ", k);
    for i in (0..max_value).rev() {
        if i == k {
            continue;
        }
        print!("{} ", i);
    }
    println!("{}", k);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;
using lint= long long int;
constexpr int MOD = 1e9 + 7;

using namespace std;
const lint max_N = 2001;
lint fac[max_N + 1000], facinv[max_N + 1000];

lint power(lint x, lint n) {
	if (n == 0) return 1LL;
	lint res = power(x * x % MOD, n / 2);
	if (n % 2 == 1) {
		res = res * x % MOD;
	}
	return res;
}

lint nCk(lint n, lint k) {
	if (k == 0 || n == k) {
		return 1;
	}
	if (n < k)
		return 0;
	if (k > n / 2)
		k = n - k;
	return fac[n] * facinv[k] % MOD * facinv[n - k] % MOD;
}

lint nPk(lint n, lint k) {
	if (k == 0 || n == k) {
		return 1;
	}
	return fac[n] * facinv[n - k] % MOD;
}

void init() {
	fac[0] = 0;
	fac[1] = 1;
	for (int i=2; i<max_N; i++) {
		fac[i] = (fac[i - 1] * i) % MOD;
	}
	for (int i=0; i<max_N; i++) {
		facinv[i] = power(fac[i], MOD - 2);
	}
}

int main() {
	int n, k;
	cin >> n >> k;
	int blue = k;
	int red = n - k;

	init();
	
	for (int i = 1; i <= k; i++) {
		cout << (nCk(red + 1, i) * (nCk(blue - 1, i - 1))) % MOD << endl;
	}
	return 0;
}


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

int main() {
    string S;
    cin >> S;
    if (S == "a" || S == "e" || S == "i" || S == "o" || S == "u") {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}


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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  string s;
  cin >> s;
  int n = s.size(), ans = 753;
  string num0;
  int num1;
  for(int i=0; i<n-2; ++i){
    num0 = s.substr(i,3);
    num1 = stoi(num0);
    ans = min(ans, abs(753 - num1));
  }
  cout << ans << endl;
  return 0;
}

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

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  int k;
  string s;
  cin >> k >> s;
  if (s.size() > k) {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  } else {
    cout << s << endl;
  }
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <set>

#define MAX_N 200000
#define LENGTH 10


using namespace std;

int N;

int main() {

    char S[MAX_N][LENGTH + 1];

    int i;
    int answer;

    set <string> s;

    scanf("%d", &N);

  for (int i = 0; i < N; i++) {
        scanf("%s", S[i]);
        s.insert(S[i]);
    }

    answer = s.size();

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

return 0;

}



Measured memory_bytes: 17704
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
//setprecision(12)
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n; cin >> n;
    vector<ll> v(100005);
    ll all = 0;
    rep(i,n) {
        ll a; cin >> a;
        v[a]++;
        all += a;
    }
    ll q; cin >> q;
    rep(i,q) {
        ll b, c; cin >> b >> c;
        all -= v[b]*b;
        all += v[b]*c;
        v[c] += v[b];
        v[b] = 0;
        cout << all << endl;
    }

    return 0;
}

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

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

int main(){
    int n;
    cin >> n;
    int N=n;
    int sum=0;

    while(n>0){
        sum+=(n%10);
        n/=10;
    }

    if(N%sum==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        var x = sc.NextChar();
        var y = sc.NextChar();
        if (x < y)
        {
            Console.WriteLine("<");
        }
        else if (x > y)
        {
            Console.WriteLine(">");
        }
        else
        {
            Console.WriteLine("=");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25828
package main

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

//=====I/O=====

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

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

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

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()
	x := scanInts(n)

	a := make([]int, n)
	a[1] = 1
	b := 1
	for i := 1; i < n-1; i++ {
		a[i+1] = (a[i]*(i+1)%mod+b)%mod
		b = b*(i+1)%mod
	}

	ans := 0

	b = 1
	for i := n-1; i > 0; i-- {
		ans = (ans+((x[i]-x[i-1])%mod)*a[i]%mod*b%mod)%mod
		b = b*i%mod
	}

	fmt.Println(ans)
	// fmt.Println(a)
}

const mod = 1000000007



Measured memory_bytes: 3840
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    int total=0;
    if(a>b)
        total=total+b;
    else
        total=total+a;
    if(c>d)
        total=total+d;
    else
        total=total+c;
    printf("%d",total);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[3010], T, b[3010], n;
ll mem[3010][3010][2];
ll dp(int x, int t, int l){
    if(t>=T || x>=n){
        return 0;
    }
    if(mem[x][t][l]!=-1)
        return mem[x][t][l];
    ll res=dp(x+1, t, l);
    if(l){
        if(a[x]+t<T){
            res=max(res, b[x]+dp(x+1, t+a[x], l));
        }
    }
    else{
        res=max(res, b[x]+dp(x+1, t+a[x], l));
        res=max(res, b[x]+dp(x+1, t, 1));
    }
    mem[x][t][l]=res;
    return res;
}
int main(){
    while(cin>>n>>T){
        ll ans=0;
        for(int i=0; i<n; ++i){
            scanf("%d%d",a+i, b+i);
        }
        memset(mem, -1, sizeof mem);
        ans=dp(0, 0, 0);
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 142080
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,m,n) for(int i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;

int main(){
  int a,b;
  cin >> a >> b;
  rrep(i,1,4){
    if(i!=a&&i!=b)cout << i;
  }
  return 0;
}


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

int main(){
    int a, b;
    char op;

    while(1){
        cin >> a >> op >> b;
        if(op == '?')break;
        
        if(op == '+')cout << a + b << endl;
        else if(op == '-')cout << a - b << endl;
        else if(op == '*')cout << a * b << endl;
        else if(op == '/')cout << a / b << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<=b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define endl "\n"
#define print(x) cout<<x<<endl;
const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}
void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}


void solve()
{
    ll a;cin>>a;
    print(a+a*a+a*a*a)
}

int main()
{
  //  fastio();
  //  test
    solve();
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  for(int i=0;i<n;i++){
    if(v[i]-c[i]>0){
      ans += v[i]-c[i];
    }
  }
  cout << ans;
  return 0;
}


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

const int mod = 1e9 + 7;

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> dp(h+1, vector<int>(w, 0));
  dp[0][0] = 1;
  for (int i = 0; i < h; i ++) {
    for (int j = 0; j < w; j ++) {
      for (int bit = 0; bit < (1 << (w-1)); bit ++) {
        bool flag = true;
        for (int k = 0; k < w - 2; k ++) {
          if (((bit >> k) & 1) && ((bit >> k + 1) & 1)) flag = false;
        }
        if (flag) {
          if (j >= 1 && ((bit >> j - 1) & 1)) {
            dp[i + 1][j - 1] += dp[i][j];
            dp[i + 1][j - 1] %= mod;
          } else if (j <= w - 2 && ((bit >> j) & 1)) {
            dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + 1] %= mod;
          } else {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
          }
        }
      }
    }
  }

  cout << dp[h][k - 1] << endl;
}

Measured memory_bytes: 256
def fib(n)
  fib = Array.new(n)
  fib[0] = 1
  fib[1] = 1
  2.upto(n) do |i|
    fib[i] = fib[i-1] + fib[i-2]
  end
  return fib[n]
end

n = gets.to_i
puts fib(n)

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

int main() {
  int A,B,C,D,L,R;
  
    cin >> A >> B >> C >> D;
  
  L = A + B;
  R = C + D;
  

  
  if ( L > R ){
    cout << "Left" <<endl;
  }
  
  else if ( L == R ) {
    cout << "Balanced" <<endl;
  }
  
  else if ( L < R ){
    cout << "Right" << endl;
  }
    
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
signed main(){
    int n;
    cin>>n;
    vi vec(n);
    REP(i,n){
        cin>>vec[i];
    }
    sort(all(vec));
    vi sum(n);
    sum[0]=vec[0];
    FOR(i,1,n){
        sum[i]=sum[i-1]+vec[i];
    }
    int ans=1;
    REPR(i,n-2){
        if(sum[i]*2<vec[i+1]){
            break;
        }
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int N; cin >> N;
    int sum = 0;
    vector<int> t(N);
    for(int i=0; i<N; ++i){ cin >> t[i]; sum += t[i]; }

    int M; cin >> M;
    vector<int> ans(M);

    for(int i=0; i<M; ++i){
        int p, x; cin >> p >> x;
        --p;
        ans[i] = sum - t[p] + x;
    }

    for(auto e:ans) cout << e << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val mod = 1000000007L
    val (h, w) = readLine()!!.split(' ').map(String::toInt)
    val map = mutableListOf(CharArray(w + 1) { ' ' })
    (1..h).forEach { map.add(CharArray(1) { ' ' } + readLine()!!.toCharArray()) }
    val dp = Array(h + 1) { LongArray(w + 1) { 0L } }
    dp[h][w] = 1
    for (th in h downTo 1) {
        for (tw in w downTo 1) {
            if (map[th][tw] == '.') {
                if (map[th - 1][tw] == '.') {
                    dp[th - 1][tw] = (dp[th - 1][tw] + dp[th][tw]) % mod
                }
                if (map[th][tw - 1] == '.') {
                    dp[th][tw - 1] = (dp[th][tw - 1] + dp[th][tw]) % mod
                }
            }
        }
    }
    println(dp[1][1])
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ll> sum(N+1, 0);
	map<ll, ll> m;
	m[0]++;
	ll ans = 0;
	for (ll ii = 0; ii < N; ++ii){
		ll a;
		cin >> a;
		sum[ii+1] = sum[ii] + a;
		m[sum[ii+1]]++;
		ans += m[sum[ii+1]] - 1;
	}

	cout << ans << endl;

	return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct vertex { ll v, w; };
struct query { ll v, L; };
vector<vertex> v;

ll MA = 100001, D = 9;

int main() {
  ll N; cin >> N;
  v.resize(1<<18); rep(i,N) cin >> v[i+1].v >> v[i+1].w;
  ll Q; cin >> Q;
  query q[Q]; rep(i,Q) cin >> q[i].v >> q[i].L;

  vector<vector<ll>> c(1<<D,vector<ll>(MA,0));
  rep(i,1<<D) repr(j,1,MA) {
    if (j<v[i].w) c[i][j] = max(c[i][j-1], c[i/2][j]);
    else c[i][j] = max(c[i/2][j], c[i/2][j-v[i].w]+v[i].v);
  }
  // rep(i,10) debug(c[i].begin(),c[i].begin()+10);


  rep(qu,Q) {
    ll dig = 0, p2 = 1; while (p2<=q[qu].v) { dig++; p2*=2; }
    ll result = 0;
    if (dig<=D) result = c[q[qu].v][q[qu].L];
    else {
      // cout << q[qu].v << " " << q[qu].L << endl;
      vertex num[1<<dig-D] = {};
      rep(i,dig-D) rep(j,1<<i) {
        num[(1<<i)+j].v = num[j].v+v[q[qu].v>>i].v;
        num[(1<<i)+j].w = num[j].w+v[q[qu].v>>i].w;
      }
      // rep(i,1<<dig-D) cout << num[i].w << "->" << num[i].v << " "; cout << endl;
      rep(i,1<<dig-D) if (num[i].w<=q[qu].L) result = max(result, c[q[qu].v>>dig-D][q[qu].L-num[i].w]+num[i].v);
    }
    cout << result << endl;
  }
  return 0;
}

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

bool prime(long long a){
  if(a==1){
    return false;
  }
  if(a==2){
    return true;
  }
  int i=2;
  while(i*i<=a){
    if(a%i==0){
      return false;
    }
    i++;
  }
  return true;
}

int main(){
  int n,i;
  cin >> n;
  int ans=0;
  bool ha;
  for(i=0;i<n;++i){
    long long a;
    cin >> a;
    ha=prime(a);
    if(ha==true){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3064
#include <stdio.h>


int main(void){
	int n;
	scanf("%d",&n);
	
	int count=0;
	int l[n],r[n];
	for(int i=0;i<n;i++){
		scanf("%d %d",&l[i],&r[i]);
		count+=(r[i]-l[i]+1);
	}
	printf("%d", count);
	
	return 0;
} 

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n; cin >> n;
    int array[n];

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

    reverse(array, array+n);

    for (int i = 0; i < n; i++) {
        if (i != 0) cout << ' ';
        cout << array[i];
    }

    cout << '\n';

    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
#include<iomanip>

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


int main()
{
	ll n;
	cin >> n;
	string s;
	cin >> s;
	char x = s[0];
	ll ans = 1;
	for (ll i = 1; i < n; i++)
	{
		if (x != s[i])
		{
			ans++;
			x = s[i];
		}
	}
	cout << ans << "\n";
	return 0;
}

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

int a[11000], b[11000];
int dp[11000];
const int INF = 1001001001;

int main() {
    int h, n;
    cin >> h >> n;
    rep(i,n) cin >> a[i] >> b[i];
    for (int i = 1; i <= h; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i <= h; i++) {
        for (int j = 0; j < n; j++) {
            if (i-a[j] >= 0) dp[i] = min(dp[i], dp[i-a[j]] + b[j]);
            else dp[i] = min(dp[i], b[j]);
        }
    }
    cout << dp[h] << endl;
}

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

using ll = long long;

class union_find {
public:
    union_find(int n) : par(n, -1) {}

    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        x = root(x), y = root(y);
        if(x == y) return false;
        if(par[x] < par[y]) std::swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

private:
    std::vector<int> par;
};

struct edge {
    int from, to;
    ll cost;
    edge(int f, int t, ll c) : from(f), to(t), cost(c) {}

    bool operator<(const edge& that) const {
        return cost < that.cost;
    }
};

using edges = vector<edge>;
using graph = vector<edges>;

constexpr int inf = 1e9;

int main() {
    int n, m; cin >> n >> m;
    edges es;
    for(int i = 0; i < m; ++i) {
        int a, b, c; cin >> a >> b >> c;
        es.emplace_back(a - 1, b - 1, c);
    }
    sort(begin(es), end(es));

    union_find uf(n);
    graph g(n);
    ll ans = 0;
    for(const auto& e : es) {
        if(uf.unite(e.from, e.to)) {
            ans += e.cost;
            g[e.from].emplace_back(e.from, e.to, e.cost);
            g[e.to].emplace_back(e.to, e.from, e.cost);
        }
    }

    vector<vector<int>> ma(n, vector<int>(n, inf));
    for(int s = 0; s < n; ++s) {
        function<void(int, int, int)> dfs = [&] (int v, int p, int cur) {
            ma[s][v] = cur;
            for(auto const& e : g[v]) {
                if(e.to == p) continue;
                dfs(e.to, v, max(cur, (int)e.cost));
            }
        };
        dfs(s, -1, 0);
    }

    int q; cin >> q;
    while(q--) {
        int s, t; cin >> s >> t;
        cout << ans - ma[s - 1][t - 1] << endl;
    }
}

Measured memory_bytes: 72040
import java.util.Scanner;

public class Main {

	final static int 	BUILDINGS = 4, // 棟数
						FLOORS = 3, // 階数
						ROOMS = 10; // 部屋数

	static int[][][] house = new int[BUILDINGS][FLOORS][ROOMS]; // 入居者を記録する

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		// 入力件数の入力
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {

			// 各情報の入力
			//入居者を変更
			ChangeTenants(sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt());
		}

		//表示
		print();
	}

	// 入居者の変更
	static void ChangeTenants(int b, int f, int r, int v) {
		// 入力データを配列の添え字に合わせ、入居者を加算
		house[b - 1][f - 1][r - 1] += v;
	}

	// 表示処理
	static void print() {
		
		for (int b = 0; b < BUILDINGS; b++) {

			for (int f = 0; f < FLOORS; f++) {

				String output = "";
				for (int r = 0; r < ROOMS; r++) {

					// 数字の前にスペースを入れる
					output += " " + house[b][f][r];
				}
				// 出力
				System.out.println(output);

			}
			// 棟が変わる場合#を20個入れる(最後の行には入れないように)
			if (b < 3) {
				System.out.println("####################");
			}
		}
	}

}


Measured memory_bytes: 29712
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]

right = 0
s = 0
ans = 0

for left in range(n):
    while right < n and s ^ a[right] == s | a[right]:
        s ^= a[right]
        right += 1
    
    ans += right - left

    if left == right:
        right += 1
    else:
        s -= a[left]

print(ans)

Measured memory_bytes: 72396
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] weights = new int[n];
		int[] sum = new int[n];
		for(int i = 0; i < n; i++){
			weights[i] = sc.nextInt();
			if(i == 0){
				sum[i] = weights[i];
			}else{
				sum[i] = weights[i] + sum[i - 1];
			}
		}
		int ans = 0;
		for(int i = 0; i < n; i++){
			if(sum[i] * 2 >= sum[n - 1]){
				ans = Math.min(Math.abs(sum[n - 1] - 2 * sum[i]),
						Math.abs(sum[n - 1] - 2 * sum[i - 1]));
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
import numpy as np

input_rad = int(input())
X, Y = 0, 0
Y = 1
t = 1
rad = input_rad

while True:
    radian = rad * np.pi / 180
    x = np.sin(radian)
    y = np.cos(radian)
    X += x
    Y += y
    t += 1
    rad += input_rad
    if abs(X) < 1.0 * np.exp(-5):
        X = 0
    if abs(Y) < 1.0 * np.exp(-5):
        Y = 0
    if X == 0:
        if Y == 0:
            print(t)
            break

Measured memory_bytes: 27156
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)
mo=10**9+7

def gcd(x,y):
    if x%y==0:
        return y
    while x%y!=0:
        x,y=y,x%y
    return y
        
#n=int(input())  
a,b,c,d=map(int,input().split())
#a=[int(i) for i in input().split()]
#a=[l+i-1 for i in range(1,n+1)]
def f(n,k):
    return n//k

def f2(a):
    #print(a,c,d,'|',f(a,c),f(a,d),f(a,c*d//gcd(c,d)))
    return a-f(a,c)-f(a,d)+f(a,c*d//gcd(c,d))
    

ans=f2(b)-f2(a-1)
print(ans)#,f2(b),f2(a-1))


Measured memory_bytes: 38256
#![allow(dead_code)]
#![allow(unused_macros)]

// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
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! {
        h: usize, w: usize
    }

    if h == 1 || w == 1 {
        println!("{}", 1);
        std::process::exit(0)
    }

    let first = if w % 2 == 0 { w / 2 } else { w / 2 + 1};
    let second = w / 2;
    let mut ans = h / 2 * (first + second);
    if h % 2 == 1 { ans += first }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	ll x, y;
	cin >> x >> y;
	int ans = 0;
	while (x <= y) {
		ans++;
		x *= 2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {

	long long n;
	cin >> n;

	long m;
	m = pow(n, 0.5);

	long f = 100;
	for (long i = 1; i <= m; i++) {
		if (n%i == 0) {
			f = min(f,max((long)(log(i) / log(10)), (long)(log(n / i) / log(10))));
		}
	}

	cout << f+1 << endl;
	return 0;

}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
#define SZ(v) ((int)(v).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
int p[200005];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>p[i];
	int Min=INF;
	int ans=0;
	for(int i=1;i<=n;i++){
		Min=min(Min,p[i]);
		if(Min>=p[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
	// your code goes here
	int a,b;
	cin>>a>>b;
	if((a==0||b==0)||(a<0&&b>0))
	{
		cout<<"Zero";
	}
	else if(a>0&&b>0)
	{
		cout<<"Positive";
	}
	else if((a<0&&b<0)&&((b-a)%2==0))
	{
		cout<<"Negative";
	}
	else
	{
		cout<<"Positive";
	}
	return 0;
}

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

const int MAXN = (int)1e5 + 1;

bool is_ac[MAXN];
int wa_num[MAXN];

int main() {
  int n, m;
  std::cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    is_ac[i] = false;
    wa_num[i] = 0;
  }
  int p;
  std::string s;
  int ac_num = 0;
  int pen = 0;
  for (int i = 0; i < m; ++i) {
    std::cin >> p >> s;
    if (is_ac[p]) continue;
    if (s == "AC") {
      is_ac[p] = true;
      ++ac_num;
      pen += wa_num[p];
    } else {
      ++wa_num[p];
    }
  }
  std::cout << ac_num << " " << pen << std::endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	bool flag = false;
	if(s.size() < t.size())
	{
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	int pos;
	for(int i = 0; i < s.size() - t.size() + 1; i++)
	{
		bool ok = true;
		for(int j = 0; j < t.size(); j++)
		{
			if(s[i + j] == t[j]) continue;
			if(s[i + j] == '?') continue;
			ok = false;
		}
		if(ok)
		{	
			flag = true;
			pos = i;
		}
	}
	for(int i = 0; i < s.size(); i++)
	{
		if(i == pos)
		{
			for(int j = 0; j < t.size(); j++)
			{
				s[i + j] = t[j];
			}
		}
	}
	if(flag)
	{
		for(int i = 0; i < s.size(); i++)
		{
			if(s[i] == '?') s[i] = 'a';
			cout << s[i];
		}
		cout << endl;
	}
	else	
		cout << "UNRESTORABLE" << endl;
	return 0;
}

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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  const int INF = 1e9 + 10;
  int ans = INF;

  rep(k, 1<<N) {
    bitset<18> bit(k);
    if (bit.count() % 2 == 1) continue;
    vector<pair<int, int>> C;
    vector<int> S(N);
    int kans = 0;
    rep(i, N) {
      if (bit[i] == 0) C.emplace_back(A[i],0);
      else C.emplace_back(B[i], 1);
      S[i] = C[i].first;
    }
    sort(S.begin(), S.end());

    for (int i = N - 1; i >= 0; i--) {
      bool check = false;
      for (int j = i; j >= 0; j--) {
        if (S[i] != C[j].first) continue;
        if ((i - j + C[j].second) % 2 == 1) continue;
        kans += i - j;
        C.erase(C.begin() + j);
        for (int x = j; x < C.size(); x++) {
          C[x].second ^= 1;
        }
        check = true;
        break;
      }
      if (!check) {
        kans = INF;
        break;
      }
    }
    ans = min(ans, kans);
  }

  if(ans == INF) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        var S = cin.next;
        if ((S[0] == S[1] && S[1] == S[2]) || (S[1] == S[2] && S[2] == S[3]))
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

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

#define FILE "filename"
#define mp make_pair
#define pb push_back

#define xx real()
#define yy imag()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;

#define DEBUG 0
#define dout if(DEBUG) cout


const double EPS = 1e-9;
const int MAXN = 1e5 + 5;


void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a^b^c);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//
//    freopen(FILE".in", "r", stdin);
//    freopen(FILE".out", "w", stdout);


    int t = 1;
    while(t--) {
        solve();
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    cout << (N+1)/2 << endl;

    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int counter = 0;
	int answer = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
			counter++;
			(counter > answer) ? answer = counter : answer = answer;
		}
		else {
			(counter > answer) ? answer = counter : answer = answer;
			counter = 0;
		}
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int n, m;
    cin >> n >> m;

    if (m >= n) {
        cout << "unsafe";
    }
    else {
        cout << "safe";
    }

    return 0;
}

Measured memory_bytes: 3604
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    loop {
        let v = read_vec::<i32>();
        if v[0] == -1 && v[1] == -1 && v[2] == -1 {
            break;
        }

        if v[0] == -1 || v[1] == -1 {
            println!("F");
        } else if v[0] + v[1] >= 80 {
            println!("A");
        } else if v[0] + v[1] >= 65 {
            println!("B");
        } else if v[0] + v[1] >= 50 {
            println!("C");
        } else if v[0] + v[1] >= 30 {
            if v[2] >= 50 {
                println!("C");
            } else {
                println!("D");
            }
        } else {
            println!("F");
        }
    }
}



Measured memory_bytes: 5028
#include<string>
#include<cctype>
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 1000 + 8;
int sta[maxn];
char c[100];
int top ;
/*
bool isEmpty(int sta[])
{
    return !top;
}*/

int pop()
{
    int x = sta[top];
    top--;
    return x;
}
void push(int x)
{
    ++top;
    sta[top] = x;
}
void add()
{
    int y = pop();
    int x = pop();
    //cout <<"x + y: " << x + y << endl;
    push(x+y);
}
void subtract()
{
    int y =  pop();
    int x =  pop();
    //cout << "x - y: " <<x - y << endl;
    push(x-y);
}

void multiple()
{
    int y = pop();
    int x = pop();
    //cout <<"x * y: "<< x * y << endl;
    push(x*y);
    //cout << sta[top] << endl;
}
void operate(char s[])
{
    int x = atoi(c);
    push(x);
}
int main()
{
    top = 0;
    while(scanf("%s",c) != EOF)
    {
        if(strcmp(c,"+") == 0){
            add();
        }else if(strcmp(c,"-") == 0){
            subtract();
        }else if(strcmp(c,"*") == 0){
            multiple();
        }else {
            operate(c);
        }
    }
    printf("%d\n",pop());
    return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(c-b==b-a){
    cout<<"YES"<<"\n";
  }
  else{
    cout<<"NO"<<"\n";
  }
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            solve(in);
        }
    }

    private static void solve(Scanner in) {
        while (in.hasNext()) {
            int n = in.nextInt();
            int count = 0;
            for (int a = 0; a <= 9; a++) {
                if (a > n) {
                    break;
                } else if (a + 27 < n) {
                    continue;
                }

                for (int b = 0; b <= 9; b++) {
                    int ab = a + b;
                    if (ab > n) {
                        break;
                    } else if (ab + 18 < n) {
                        continue;
                    }

                    for (int c = 0; c <= 9; c++) {
                        int abc = ab + c;
                        if (abc > n) {
                            break;
                        } else if (abc + 9 < n) {
                            continue;
                        } 

                        int d = n - abc;
                        if (d >= 0 && d <= 9) {
                            count++;
                        }
                    }
                }
            }
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 26100
#include <bits/stdc++.h>
    #define ll long long
    #define f(i, a, b) for(ll i=a; i<b; i++)
    #define pb push_back
    #define mp make_pair
    #define F first
    #define S second
    using namespace std;
    ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
    {
        unordered_map<ll, ll> prevSum;
        ll res = 0;
        ll currsum = 0;
        for (ll i = 0; i < n; i++)
        {
            currsum += arr[i];
            if (currsum == sum) res++;
            if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
            prevSum[currsum]++;
        }
        return res; 
    } 
    ll gcd(ll a, ll b) 
    { 
        if (a == 0) 
            return b; 
        return gcd(b % a, a); 
    } 
      
    ll findGCD(ll arr[], ll n) 
    { 
        ll result = arr[0]; 
        for (ll i = 1; i < n; i++)
            result = gcd(arr[i], result); 
      
        return result; 
    } 
    ll powmp(ll x, ll y, ll p) 
    { 
        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; 
    } 
     
    int main()
    {
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        ll a,b;cin>>a>>b;
      ll x=a*b;
      if(a<10 && b<10) cout<<x;
      else cout<<"-1";
    }

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007


signed main(){
    int k[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    cout<<k[K-1]<<endl;
}


Measured memory_bytes: 3132
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String str = sc.next();
        
        if(str.length() > K){
            str = str.substring(0,K) + "...";
        }

        System.out.println(str);
    }
}


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

using namespace std;
#define BUF (200005)
#define ll long long 

ll n;
ll s[BUF];
ll ans = 0;

int main(void){
	cin >> n;
	for(ll i=1;i<=n;++i){
		ll tmp;
		cin >> tmp;
		s[i] = s[i-1]+tmp;
	//	if(tmp==0)ans++;
	}
	sort(s,s+n+1);

	ll j = 0;
	while(j<=n){
		ll num = s[j];
		ll cnt = 0;
		while(num==s[j] && j <= n){
			j++;
			cnt++;
		}
		ans+=cnt*(cnt-1)/2;
	}	

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1792