akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int N;
long long a[100010][3];
long long dp[100010][3];

int main(){
    int N; cin >> N;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < 3; j++) 
            cin >> a[i][j];

    for (int i = 0; i < N; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (j==k) continue;
                dp[i+1][k]=(dp[i+1][k]> dp[i][j]+a[i][k] )? dp[i+1][k] : dp[i][j]+a[i][k] ;
            }
        }        
    }
    long long m = max(dp[N][0],max(dp[N][1],dp[N][2]));
    cout << m << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> vec(N);
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  int AC = 0;
  int WA = 0;
  int TLE = 0;
  int RE = 0;
  for (int i = 0; i < N; i++){
    if (vec.at(i) == "AC"){
      AC++;
    }
    if (vec.at(i) == "WA"){
      WA++;
    }
    if (vec.at(i) == "TLE"){
      TLE++;
    }
    if (vec.at(i) == "RE"){
      RE++;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}



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

using namespace std;

int main() {
    long long int n,i,j,k;
    cin>>n>>k;
    long long int a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    b[0]=0;
    b[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {   b[i]=b[i-1]+abs(a[i-1]-a[i]);
        for(j=i-1;j>=0 && i-j<=k;j--)
        {
            b[i]=min(b[j]+abs(a[j]-a[i]),b[i]);
        }
        //cout<<b[i]<<" ";
    }
    cout<<b[n-1];
    
}

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

const int INF = 1000000000;

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

    int d[m][m];
    for(int i=0; i<m; i++){
      for(int j=0; j<m; j++){
        d[i][j] = T[i][j];
      }
    }

    for(int h=0; h<m; h++){
      for(int i=0; i<m; i++){
        for(int j=0; j<m; j++){
          if(d[i][j] > d[i][h]+d[h][j]){
            d[i][j] = d[i][h]+d[h][j];
          }
        }
      }
    }

    int ttl=0;
    int min=0;
    for(int i=0; i<m; i++){
      int t=0;
      for(int j=0; j<m; j++){
        t += d[i][j];
      }
      if(ttl==0 || ttl>t){
        ttl=t;
        min=i;
      }
    }

    cout << min << " " << ttl << '\n';
	}

	return 0;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;

int main(){
	int n;
	cin >> n;
	int k;
	cin >> k;
	vector<int> x(n);

	int ans = 0;
	
	for(int i = 0;i < n;i++){
		int x;
		cin >> x;
		ans += 2 * min(k - x,x);
	}

	cout << ans << endl;
}


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

using namespace std;

#define pb push_back
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef pair <ll, ll> pi;

ll a, b, c, d, x, y, ans;

int main() {
    cin >> a >> b >> c >> x >> y;
    d = min(a + b, 2 * c);
    if (x > y) {
        ans += (x - y) * min(2 * c, a);
        x = y;
    } else {
        ans += (y - x) * min(2 * c, b);
        y = x;
    }
    ans += d * x;
    cout << ans << endl;
}

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

#ifdef LOCAL
#define dbg(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define dbg(...) 17;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; }
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) { bool f = true; os << "{"; for (const auto &x : c) { if (!f) os << ", "; f = false; os << x; } return os << "}"; }
template<typename T> void debug(string s, T x) { cerr << s << " = " << x << "\n"; }
template<typename T, typename... Args> void debug(string s, T x, Args... args) { cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...); }

int main() {
    const int INF = 1e9;
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    set<pair<int, int>> pos;
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        pos.emplace(x[i], i);
    }
    int d = 0;
    while ((1 << d) < n) {
        d++;
    }
    vector<vector<int>> fgo(n, vector<int>(d + 1, INF));
    vector<vector<ll>> fsum(n, vector<ll>(d + 1, -1));
    vector<vector<int>> bgo(n, vector<int>(d + 1, -INF));
    vector<vector<ll>> bsum(n, vector<ll>(d + 1, -1));
    for (int i = 0; i < n; i++) {
        auto it = pos.lower_bound({x[i] + k, -INF});
        if (it != pos.end()) {
            fgo[i][0] = (*it).second;
            fsum[i][0] = (*it).second;
        }
        it = pos.lower_bound({x[i] - k, INF});
        if (it != pos.begin()) {
            it = prev(it);
            bgo[i][0] = (*it).second;
            bsum[i][0] = (*it).second;
        }
    }
    for (int i = 0; i <= d; i++) {
        for(int j = 0; j < n; j++) {
            if (!(fgo[j][i] == INF || fgo[fgo[j][i]][i] == INF)) {
                fgo[j][i + 1] = fgo[fgo[j][i]][i];
                fsum[j][i + 1] = fsum[j][i] + fsum[fgo[j][i]][i];
            }
            if (!(bgo[j][i] == -INF || bgo[bgo[j][i]][i] == -INF)) {
                bgo[j][i + 1] = bgo[bgo[j][i]][i];
                bsum[j][i + 1] = bsum[j][i] + bsum[bgo[j][i]][i];
            }
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        int fcur = l;
        int bcur = r;
        ll ftot = l;
        ll btot = r;
        int tot = 1;
        for (int i = d; i >= 0; i--) {
            if (fgo[fcur][i] <= r) {
                ftot += fsum[fcur][i];
                tot += (1 << i);
                fcur = fgo[fcur][i];
            }
            if (bgo[bcur][i] >= l) {
                btot += bsum[bcur][i];
                bcur = bgo[bcur][i];
            }
        }
        cout << btot - ftot + tot << '\n';
    }
    return 0;
}


Measured memory_bytes: 132036
S_str = input()
S = [int(i) for i in S_str]
N = len(S)

ans = 0
for bit in range(1 << (N-1)):
  f = S[0]
  g = S_str[0]
  for i in range(N-1):
    if bit & (1 << i):
      f += S[i+1]
      g += "+"+S_str[i+1]
    else:
      f -= S[i+1]
      g += "-"+S_str[i+1]
  if f == 7:
    print(g+"=7")
    exit()

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

using namespace std;

int n;
string s;

long long f(int i) {
    if (i == n) return 0;
    long long ans = 0;
    for (int j = 1; i + j <= n; ++j) {
        long long num = stol(s.substr(i, j));
        int rest = n - i - j;
        if (rest >= 1) num *= 1 << (rest - 1);
        ans += num + f(i + j);
    }
    return ans;
}

int main()
{
    cin >> s;
    n = s.size();
    cout << f(0) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


int main(){
    int n,m;
    cin >> n >> m;
    set<int> s[n+1];

    rep(i,0,m){
	int a,b;
	cin >> a >> b;
	s[a].it(b);
	s[b].it(a);
    }

    vi v(n-1);
    rep(i,0,n-1)v[i] = i+2;

    ll ans = 0;
    do{
	int f = 0;
	if(s[1].count(v[0]) == 0){
		f = 1;
	}
	rep(i,0,n-2){
	    if(s[v[i]].count(v[i+1]) == 0){
		f = 1;
		break;
	    }
	}
	if(f == 0)ans++;
    }while(next_permutation(v.begin(), v.end()));

    P(ans);
    return  0;
}


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

using namespace std;

typedef long long ll;

int arr[1000007];
int ans[1007][1007];
vector<int> v;

int main ()
{
    int n, m, h, w, i, j, k, l, x, y;
    cin >> h >> w;
    cin >> n;
    for (i=1; i<=n; i++)
    {
        cin >> arr[i];
        for (j=1; j<=arr[i]; j++)
        {
            v.push_back(i);
        }
    }
    int now=0;
//    if (v.size()>h*w)
//    {
//        cout << "WA" << endl;
//        return 0;
//    }
//    cout << v.size() << endl;
    for (i=0; i<h; i++)
    {
        if (i%2==0)
        {
            for (j=0; j<w; j++)
            {
                ans[i][j] = v[now];
                now++;
            }
        }
        else
        {
            for (j=w-1; j>=0; j--)
            {
                ans[i][j] = v[now];
                now++;
            }
        }
    }
    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2816
use std::io;


fn main() {
    let n = read_one::<usize>();
    let mut sn = Vec::new();
    for _ in 0..n { sn.push(read_one::<usize>()); }
    let s = sn.iter().sum::<usize>();
    
    if sn.iter().all(|s| s % 10 == 0) {
        println!("0");
        return;
    }

    let min = sn.iter()
        .filter(|s| *s % 10 != 0)
        .min().unwrap();
    if s % 10 == 0 {
        println!("{}", s - min);
    } else {
        println!("{}", s);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

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

	int num = 1,ans;

	for(int i = 0; i < 20; i++){

		num *= 2;
		if(num > N)break;

		ans = num;
	}

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

	return 0;
}



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

signed main()
{
  string a, b;
  cin >> a >> b;
  int n = a.size(), m = b.size();

  vector<vector<int>> suma(n + 1, vector<int>(26));
  vector<vector<int>> sumb(m + 1, vector<int>(26));

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < 26; j++)
    {
      if (a[i] - 'a' == j)
        suma[i + 1][j]++;
      suma[i + 1][j] += suma[i][j];
    }
  }
  for (int i = 0; i < m; i++)
  {
    for (int j = 0; j < 26; j++)
    {
      if (b[i] - 'a' == j)
        sumb[i + 1][j]++;
      sumb[i + 1][j] += sumb[i][j];
    }
  }

  for (int len = min(n, m); len >= 0; len--)
  {
    set<vector<int>> st;
    for (int i = 0; i < n; i++)
    {
      if (i + len > n)
        break;
      vector<int> v(26);
      for (int k = 0; k < 26; k++)
      {
        v[k] = suma[i + len][k] - suma[i][k];
      }
      st.emplace(v);
    }
    for (int i = 0; i < m; i++)
    {
      if (i + len > m)
        break;
      vector<int> v(26);
      for (int k = 0; k < 26; k++)
      {
        v[k] = sumb[i + len][k] - sumb[i][k];
      }
      if (st.count(v))
      {
        cout << len << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}



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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

ll comp(string s, string t)
{
	ll ret = 0;
	ll n = len(s);
	f(i,0,n-1) if(s[i] != t[i]) ret++;
	return ret;
}

int main()
{
    Fast_IO();
    string s, t; cin >> s >> t;
    ll n = len(s), m = len(t);
    ll ans = m;
    f(i,0,n-m) ans = min(ans, comp(s.substr(i,m),t));
    cout << ans;
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    string S;
    cin >> S;

    vector<ll> R(N, 0);
    vector<ll> W(N, 0);

    if(S[0] == 'R'){
        R[0] = 1;
    }
    else{
        W[0] = 1;
    }

    for(ll i=1; i<N; i++){
        if(S[i] == 'R'){
            R[i] = R[i-1] + 1;
            W[i] = W[i-1];
        }
        else{
            R[i] = R[i-1];
            W[i] = W[i-1] + 1;
        }
    }

    ll Rtotal = R[N-1];
    ll Wtotal = W[N-1];

    ll ans = LINF;
    REP(i, N){
        ll Rx = R[i];
        ll Wx = W[i];
        ll Ry = Rtotal - R[i];
        ll Wy = Wtotal - W[i];

        // cout << "i:" << i << " Rx:" << Rx << " Wy:" << Wy << endl;
        ans = min(ans, max(Wx, Ry));
    }

    ans = min(ans, Rtotal);
    ans = min(ans, Wtotal);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6724
#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <bitset>

using namespace std;
#define max 31

int h, w, n;
char map[max][max];
string ans[] = { "NO", "YES" };

int getlen( char tmap[max][max], char ttmap[max][max], char target, int x, int y, int dx, int dy, int depth, bool mode) {
	if( x < 0 || x >= w || y < 0 || y >= h ) return depth;
	if( tmap[y][x] != target ) return depth;
	if( mode == true ) ttmap[y][x] = '.';
	return getlen( tmap, ttmap, target, x + dx, y + dy, dx, dy, depth + 1, mode);
}

//posは左側の座標
bool search(int pos[2]){
	if( pos[1] >= w - 1 ) return false;
	bool ret = true, flg = true;
	char tmap[max][max];
	memcpy( tmap, map, sizeof(map) );

	//入れ替え
	if( tmap[pos[0]][pos[1]] != tmap[pos[0]][pos[1] + 1] && pos[0] >= 0 ) {
		tmap[pos[0]][pos[1]] = tmap[pos[0]][pos[1]] ^ tmap[pos[0]][pos[1] + 1];
		tmap[pos[0]][pos[1] + 1] = tmap[pos[0]][pos[1]] ^ tmap[pos[0]][pos[1] + 1];
		tmap[pos[0]][pos[1]] = tmap[pos[0]][pos[1]] ^ tmap[pos[0]][pos[1] + 1];
	}
	
	while( flg ) {
		flg = false;
		//落下
		for(int i = 0; i < w; i++) {
			int tmp = 0;
			char ch[max];
			for(int j = 0; j < h; j++) {
				if( tmap[j][i] != '.' ) {
					ch[tmp] = tmap[j][i];
					tmp ++;
				}	
			}
			for(int j = h - 1; j >= 0; j--) {
				if( tmp > 0 ) {
					tmap[j][i] = ch[tmp - 1];
					tmp --;
				} else {
					tmap[j][i] = '.';
				}
			}
		}
	

		int dis[2][max][max];

		for(int i = 0; i < 2; i++)
			for(int j = 0; j < 30; j++)
				for(int k = 0; k < 30; k++)
					dis[i][j][k] = 0;

		char ttmap[max][max];
		memcpy( ttmap, tmap, sizeof( tmap ) );
		//消滅チェック
		
		for(int j = 0; j < h; j++) {
			for(int i = 0; i < w; i++) {
				if( tmap[j][i] == '.' ) continue;
				dis[1][j][i] = getlen( tmap, tmap, tmap[j][i], i, j, -1, 0, 0, false ) + getlen( tmap, tmap, tmap[j][i], i, j, 1, 0, 0, false );
				dis[0][j][i] = getlen( tmap, tmap, tmap[j][i], i, j, 0, -1, 0, false ) + getlen( tmap, tmap, tmap[j][i], i, j, 0, 1, 0, false );
			}
		}

		//消滅
		for(int i = 0; i < w; i++) {
			for(int j = 0; j < h; j++) {
				if( tmap[j][i] == '.' ) continue;
				if( dis[1][j][i] >= n + 1 ) {
					flg = true;
					getlen( tmap, ttmap, tmap[j][i], i, j, -1, 0, 0, true );
					getlen( tmap, ttmap, tmap[j][i], i, j, 1, 0, 0, true );
				}
				if( dis[0][j][i] >= n + 1) {
					flg = true;
					getlen( tmap, ttmap, tmap[j][i], i, j, 0, -1, 0, true );
					getlen( tmap, ttmap, tmap[j][i], i, j, 0, 1, 0, true );
				}
			}
		}
		
		memcpy( tmap, ttmap, sizeof( tmap ) );

	}
	


	//全消しチェック
	for(int i = 0; i < w; i++) {
		for(int j = 0; j < h; j++) {
			if( tmap[j][i] != '.' ) ret = false;
		}
		if( !ret ) break;
	}

	return ret;
}

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	
	cin >> h >> w >> n;
	
	for(int i = 0; i < h; i++)
		cin >> map[i];
	
	int pos[2] = {0, 0};
	bool flg = false;

	for(pos[0] = 0; pos[0] < h; pos[0] ++) {
		for(pos[1] = 0; pos[1] < w; pos[1] ++) {
			flg |= search( pos );
		}
	}

	cout << ans[flg] << endl;
	//while(1){}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int NMAX = 200010;
// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod; return *this;}
  mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod; return *this;}
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(NMAX);

struct node {
  mint val = 1;
  int t = 0;
  node(mint val=1, int t=0):val(val),t(t){}
  node operator+(const node& x) {
    return node(val*x.val*c(t+x.t,t), t+x.t);
  }
};

vector<int> g[NMAX];
vector<node> dp[NMAX];
node ans[NMAX];

node dfs(int u, int p = -1){
  node res;
  rep(i,g[u].size()){
    int v = g[u][i];
    if(v!=p){
      res = res + (dp[u][i] = dfs(v,u));
    }
  }
  res.t++;
  return res;
}
void f(int u, const node& dpi=node(), int p=-1) {
  int n = g[u].size();
  rep(i,n) if(g[u][i]==p) dp[u][i] = dpi;
 
  vector<node> l(n+1), r(n+1);
  rep(i,n) l[i+1] = l[i] + dp[u][i];
  rep(i,n) r[n-1-i] = r[n-i] + dp[u][n-1-i];
  
  ans[u] = l[n];
  rep(i,n) {
    int v = g[u][i];
    if (v==p) continue;
    node d = l[i] + r[i+1];
    d.t++;
    f(v,d,u);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  rep(i,n) dp[i] = vector<node>(g[i].size());
  dfs(0);
  f(0);
  rep(i,n) cout << ans[i].val << endl;
}


Measured memory_bytes: 38516
N, T = map(int, input().split())
c = []
t = []
for i in range(N):
	a, b = map(int, input().split())
	c.append(a)
	t.append(b)

ans = 1e5
for i in range(N):
	if t[i] <= T:
		ans = min(ans, c[i])
if (ans == 1e5) : print("TLE")
else : print(ans)


Measured memory_bytes: 3060
chomp (my ($n, $m) = split / /, <STDIN>);
my $MOD = 1e9 + 7;
my (@a, @dp);
$dp[0] = 1;
for my $i (1..$m) {
  chomp (my $in = <STDIN>);
  $a[$i] = $in;
  $dp[$a[$i]] = -1;
}
for my $i (0..$n - 1) {
  next if $dp[$i] == -1;
  if ($dp[$i + 1] != -1) {
    $dp[$i + 1] += $dp[$i];
    $dp[$i + 1] %= $MOD;
  }
  if ($dp[$i + 2] != -1) {
    $dp[$i + 2] += $dp[$i];
    $dp[$i + 2] %= $MOD;
  }
}
print $dp[$n] + 0, "\n";

Measured memory_bytes: 12288
import sys
from decimal import *
import math

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A, B = input().split()

if A == "0":
    print(0)
    exit()

getcontext().prec = 10 ** 10

ANS = Decimal(A) * Decimal(B)
print((math.floor(ANS)))


Measured memory_bytes: 10012
#include<cstdio>
const int N=1e5+3;
struct edge{int v,nxt;}g[N+N];
int n,head[N],k,f[N];
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs(int u,int fa){
	int v;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa)
	  Dfs(v,u),f[u]^=f[v]+1;
}
int main(){
	int u,v;
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	  scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	Dfs(1,0);
	puts(f[1]?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 7168
from collections import defaultdict, deque
dic = defaultdict(list)

N, M = map(int, input().split())
hint= [-1]*N

for _ in range(M):
    x, y, z = map(int, input().split())
    dic[x].append(y)
    dic[y].append(x)
    hint[x-1]=0
    hint[y-1]=0
    
count = 0
ans=0
for i in range(N):
    if hint[i]==0:
        count+=1
        hint[i]=count
        queue = deque()
        for j in dic[i+1]:
            if hint[j-1]==0:
                queue.append(j)
                hint[j-1]=count
        while queue:
            x = queue.popleft()
            for k in dic[x]:
                if hint[k-1]==0:
                    hint[k-1]=count
                    queue.append(k)        
        continue
    elif hint[i]==-1:
        ans+=1
print(ans+count)


Measured memory_bytes: 102924
#include<stdio.h>
#include<string.h>
#define STRINGLENGTH 101
int main (void){

    char s[STRINGLENGTH],ring[2*STRINGLENGTH],p[STRINGLENGTH];

    scanf("%s",s);
    scanf("%s",p);

    strcat(ring,s);
    strcat(ring,s);
    if ( strstr(ring, p) == NULL ) {printf("No\n");}
        else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int x,n; cin >> x >> n;
    map<int,int> m;
    rep(i,n){
        int x; cin >> x;
        m[x]++;
    }
    int a = 0; int ans = 1e9; int num = x;
    while(a <= 101){
        if(m[a] == 0){
            if(ans > abs(x-a)){
                ans = abs(x-a);
                num = a;
            }
        }
        a++;
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 3636
import numpy as np
mod = 998244353
N, S = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
coef = np.zeros(3001, dtype=int)
ans = 0
for a in A:
    coef[0] += 1
    coef[a:] += coef[:-a]
    coef %= mod
    ans += coef[S]
    ans %= mod
print(ans)


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

int main(){
  int n, a, b;
  int res=0;
  cin >> n >> a >> b;

  for(int i=0; i<=n; i++){
    int m = i/10000 + (i%10000)/1000 + (i%1000)/100 + (i%100)/10 + i%10;

    if(m>=a && m<=b) res += i;
  }

  cout << res << endl;

  return 0;

}


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

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

#define READ(x) (cin >> (x))

#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))

int main() {
    // get values from input
    int K, N;
    READ(K);
    READ(N);

    vector<int> A(N);
    REP(i, N) {
        READ(A[i]);
    }

    // main procedure
    int longest_next_distance = -1;

    REP(i, N) {
        int next_distance;

        if (i == N - 1) {
            next_distance = A[0] - A [i] + K;
        } else {
            next_distance = A[i + 1] - A[i];
        }
        if (next_distance > longest_next_distance) {
            longest_next_distance = next_distance;
        }
    }

    int ans = K - longest_next_distance;

    // output
    WRITE_N(ans);

    return 0;
}


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

int main(void){
    int x, y, max_x, max_y, num_cannot_pass;
    while(std::cin >> max_x >> max_y >> num_cannot_pass){
        if(max_x == 0 && max_y ==0)
            break;
        std::vector<std::vector<int> > crossing(max_x + 1, std::vector<int>(max_y + 1, 0));
        
        crossing[1][1] = 1;
        for(int i = 1; i <= num_cannot_pass; ++i){
            std::cin >> x >> y;
            crossing[x][y] = -1;
        }
        for(int i = 1; i <= max_x; ++i){
            for(int j = 1; j <= max_y; ++j){
                if(i != 1 || j != 1){
                    if(crossing[i][j] == -1){
                        crossing[i][j] = 0;
                        continue;
                    }
                    crossing[i][j] = crossing[i - 1][j] + crossing[i][j - 1];
                }
            }
        }
        std::cout << crossing[max_x][max_y] << std::endl;
    }
}

Measured memory_bytes: 1220
def main():
    N, P = map( int ,input().split())
    S = [ int(s) for s in list(input())][::-1]
    if P == 2 or P == 5:
        ans = 0
        for i in range(N):
            if S[i]%P == 0:
                ans += N-i
        print(ans)
        return
    L = [0]*P
    L[0] = 1
    t = 0
    s = 1
    for i in range(N):
        t = (S[i]*s+t)%P
        L[t] += 1
        s = s*10%P
    ans = 0
    for l in L:
        ans += l*(l-1)//2
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 6436
def gcd(a, b):
  if a%b == 0:
    return b
  else:
    return gcd(b, a%b)
def mgcd(l):
  if len(l) == 1:
    return l[0]
  else:
    new_l = []
    for i in range(-(-len(l)//2)):
      temp = gcd(l[i], l[-i-1])
      if temp == 1:
        return 1
      else:
        new_l.append(temp)
    return mgcd(new_l)

n = int(input())
a = list(map(int, input().split()))
a.sort()
ans1 = mgcd(a[1:])
min_gcd = 1001001001
min_idx = 0
for i in range(1,n):
  temp = gcd(a[0], a[i])
  if temp < min_gcd:
    min_gcd = temp
    min_idx = i
a.pop(min_idx)
ans2 = mgcd(a)
print(max(ans1, ans2))
  

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

int main()
{
	int n;
  	string s;
  cin >> n >> s;
  if(n%2>0)
    cout << "No";
  else{
    string r1 = s.substr(0,n/2);
  	string r2 = s.substr(n/2,n);
  	if(r1==r2)
      cout << "Yes";
  	else
      cout << "No";}
  return 0;
}

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

const int N=100010;
int dp[N][3];

int main(){
  int n;scanf("%d", &n);
  vector<int> a(n), b(n), c(n);

  for(int i=0;i<n;i++)
    scanf("%d%d%d", &a[i], &b[i], &c[i]);

  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  for(int i=1;i<n;i++)
  {
    dp[i][0]=a[i]+max(dp[i-1][1], dp[i-1][2]);
    dp[i][1]=b[i]+max(dp[i-1][0], dp[i-1][2]);
    dp[i][2]=c[i]+max(dp[i-1][0], dp[i-1][1]);
  }
  printf("%d\n", max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])));
}


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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/
#define MAX_N 2005

int N, K;
vector <int> allC[MAX_N];
int par[MAX_N];
int dp[MAX_N][MAX_N];
int newDP[MAX_N];
int sz[MAX_N];

vector <int> allE[MAX_N];

int ans(INF);
void makeTree (int c) {
    FO (i,0,allE[c].size()) {
        if (allE[c][i] != par[c]) {
            int nx = allE[c][i];
            par[nx] = c;
            allC[c].push_back (nx);
            makeTree(nx);
            sz[c] += sz[nx];
        }
    }
    sz[c]++;
}

void doDP(int c) {
    FO (i,0,allC[c].size()) doDP(allC[c][i]);
    FO (i,0,allC[c].size()) {
        int cC = allC[c][i];
        for (int p = K-1; p >= 0; p--) {
            dp[cC][p+1] = dp[cC][p];
        }
        dp[cC][0]++;
        FO (p,0,K+1) {
            newDP[p] = INF;
        }
        FO (p,0,K+1) {
            int oth = K-p;
            newDP[p] = min(dp[c][p]+dp[cC][min(p,oth)],dp[c][min(p,oth)]+dp[cC][p]);
        }
        FO (p,0,K+1) dp[c][p] = newDP[p];
        FO (p,1,K+1) dp[c][p] = min(dp[c][p],dp[c][p-1]);
    }
    ans = min (ans, dp[c][K]+N-sz[c]);
    /*FO (p,0,K+1) {
        printf ("dp[%d][%d]: %d\n", c, p, dp[c][p]);
    }*/
}

int main() {
    scanf ("%d %d", &N, &K);
    FO (i,0,N-1) {
        int _a, _b;
        scanf ("%d %d", &_a, &_b);
        allE[_a].push_back (_b);
        allE[_b].push_back (_a);
    }
    makeTree(1);
    doDP(1);
    printf ("%d\n", ans);
    return 0;
}


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


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<string> S(N);
	rep(i,N)cin>>S[i];
	
	mcf_graph<int,int> G(N*M + 2);
	
	int s = N*M,t = N*M+1;
	int ans = 0;
	rep(i,N){
		rep(j,M){
			if(S[i][j]=='#')continue;
			if(i!=N-1){
				if(S[i+1][j]!='#'){
					G.add_edge(i*M+j,(i+1)*M+j,Inf,0);
				}
			}
			if(j!=M-1){
				if(S[i][j+1]!='#'){
					G.add_edge(i*M+j,i*M+j+1,Inf,0);
				}
			}
			G.add_edge(i*M+j,t,1,(N+M) - (i+j));
			if(S[i][j]=='o'){
				G.add_edge(s,i*M+j,1,0);
				ans -= i;
				ans -= j;
				ans += (N+M);
			}
		}
	}
	
	ans -= G.flow(s,t).second;
	
	cout<<ans<<endl;
	
	return 0;
}
 

Measured memory_bytes: 4204
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
#define ll long long
int n;
char s[4005];
int num[4005];
ll a,b,c,ans;
int main()
{
	scanf("%d",&n);
	scanf("%s",s);
	for(int i=1;i<=n;i++)
	{
		if(s[i-1]=='R'){num[i]=0;a++;}
		else if(s[i-1]=='G'){num[i]=1;b++;}
		else if(s[i-1]=='B'){num[i]=2;c++;}
	}
	int l,r;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i-j<1||i+j>n)break;
			if(num[i]!=num[i-j]&&num[i]!=num[i+j]&&num[i-j]!=num[i+j])ans++;
			
		}
	}
	printf("%lld",a*b*c-ans);
	
	return 0;
} 

Measured memory_bytes: 3844
#include <iostream>
using namespace std;
int main() {
	int K; int S; cin >> K >> S;
	int cnt = 0;
	for (int x = 0; x <= K; x++) {
		for (int y = x; y <= K; y++) {
			for (int z = y; z <= K; z++) {
				if (x + y + z != S) continue;
 
				if (x != y && y != z && z != x) {
					cnt += 6; continue;
				}
				if (x == y && y == z && z == x) {
					cnt++; continue;
				}
				cnt += 3;
 
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    int c = b- a;
    int sum = 0;
    reps(i, c){
        sum += i;
    }
    cout << sum - b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
const int INFTY = (1 << 21); // 2097152
// const ll INFTY = (1LL << 60);
const ll MD = 1000000007LL;
// fprintf(stderr, "%d %lld \n", x, xll);


int N;
int main() {
	cin >> N;
	int ret;
	rep(i, N){
		int a, b; cin >> a >> b;
		ret += (b - a) + 1;
	}
	cout << ret << endl;
}

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

int gcd(int a, int b) {
  return b?gcd(b,a%b):a;
}

int main(){
  int k,ans=0;cin>>k;
  REP(i,k) REP(j,k) REP(l,k){
    ans+=gcd(i,gcd(j,l));
  }
  cout<<ans;  
}


Measured memory_bytes: 3592
#if 0
2019.12.17

假设一共有 x 种颜色，那么合法 a 的值不是 x - 1 就是 x ，
其中若 a[i] = x - 1 说明 i 的颜色是唯一的，否则说明存在另一个点与之颜色相同。
设有 k 个点满足 a[i] = x - 1 ，其他 n - k 个点满足 a[i] = x ，
那么去掉这 k 个点的影响，a 合法当且仅当能将 n - k 个点分配 x - k 种颜色，
满足每个颜色都有至少两个点，这是很好 O(1) 判断的。
需要特判的是颜色两两不同，也就是 k = n 的情况。
#endif
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	inline operator ll () { ll x; return scanf("%lld", &x), x; }
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator ()(a...); }
} read;

const int maxn = 100005;
int a[maxn];

inline bool check(int n, int m) {
	return 1 <= m and m <= n / 2;
}

int main() {
	int n = read, max = 0;

	for(int i = 1; i <= n; i ++)
		max = std::max(max, a[i] = read);

	int tot = 0;
	for(int i = 1; i <= n; i ++)
		if(a[i] == max - 1)
			++ tot;
		else if(a[i] < max - 1)
			return puts("No"), 0;

	if(tot == 0 and max == n - 1)
		return puts("Yes"), 0;

	if(check(n - tot, max - tot)) puts("Yes");
	else puts("No");
}


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

using namespace std;

int main(){
	int flag=0,C=0,count=0;
	string S;
	cin >> S;
	if(S[0]!='A'){flag=1;}
	if('a'<=S[1] && S[1]<='z'){count++;}
	for(int i=2;i<S.length()-1;i++){
		if(S[i]=='C'){C++;}
		else if('a'<=S[i] && S[i]<='z'){count++;}
	}
	if('a'<=S[S.length()-1] && S[S.length()-1]<='z'){count++;}
	if(flag==0 && C==1 && count==S.length()-2){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
    In the name of
        "ALLAH"
    And say "AL-HAMD-U-LILLAH"
*/

#include<bits/stdc++.h>
#define   ll   long long
#define   llu  unsigned long long
#define   _    printf("\n")
int      take() {
    int n;
    scanf("%d",&n);
    return n;

}
double  ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll     takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define  Int            take()
#define  Dnt            ttake()
#define  LL             takes()
#define  done           {return 0;}
#define  fr(i,x,n,a)    for(int i=x;i<=n;i+=a)
#define  FR(a,b,x)      for(int i=(a);i<=(b);i+=(x))
#define  rfr(i,x,n,a)   for(int i=x;i>=n;i--)
int      cas;
#define  print          printf("Case %d:",++cas)
#define  vi             vector<int>
#define  vl              vector<ll>
#define  pb              push_back
#define  pii             pair<int,int>
#define  vii             vector<pii>
#define  pll             pair<ll,ll>
#define  pil             pair<int,ll>
#define  pli             pair<ll,int>
#define  mk              make_pair
#define  fill(x,v)       memset(x,v,sizeof x)

using    namespace      std;

bool     approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define  STR            {struct info}
#define  dbg(x)         {cout<<"ekhane"<<x<<endl;}
#define  SS             second
#define  FF             first
#define  PQ             priority_queue
#define  great          greatest
#define  less           lesser
#define  mii            map<int,int>
#define  mil            map<int,ll>
#define  mll            map<ll,ll>
#define  msb            map<string,bool>
#define  V              vector
#define  M              100005
#define  pf             printf
//////////////////////////////////////////


int main(){

   int n = Int , val[ n + 1 ];
    pii arr[ n + 1 ] ;

   fr( i , 1 , n , 1 ) arr[ i ].FF = ( val[ i ] = Int )  , arr[ i ].SS = i ;

   sort( arr + 1 , arr + 1 + n ) ;

   int ans[ n + 1 ] ;

   rfr( i , n , 1 , 1 ){
        if( i > ( n / 2 ) ){
            ans[ arr[ i ].SS ] = arr[ n / 2 ].FF ;
        }else{
            ans[ arr[ i ].SS ] = arr[ ( n / 2 ) + 1 ].FF ;
        }
   }

   fr( i , 1 , n , 1 ) pf("%d\n", ans[ i ] );

    done;
}




Measured memory_bytes: 5248
#include <bits/stdtr1c++.h>

using namespace std;
#define TASK "solve"

const int N = 3e5 + 100;
const int module = 1e9 + 7;
const long long Base = 500000004;
void doc() {
    //freopen(TASK ".inp","r",stdin);
    //freopen(TASK ".out","w",stdout);
}
void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int F[n + 1];
    F[0] = 0;
    for (int i = 1; i <= n; i++) F[i] = F[i - 1] + (s[i - 1] == '#');
    int Res = F[n];
    int SL = 0;
    for (int i = n; i >= 1; i--) {
        Res = min(Res,F[i - 1] + (s[i - 1] == '.' ? ++SL : SL));
        cerr << SL << " " << Res << '\n';
    }
    //cout << SL << '\n';
    cout << Res;
}

int main() {
    srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    doc();
    solve();
}



Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int a,b;cin>>a>>b;
    cout<<(b-1+a-1-1)/(a-1)<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>

using namespace std;

int main() {
	
	int a, b, c, d;

	cin >> a >> b >> c >> d;
	int ans = 0;
	ans = min(b, d) - max(a, c);
	ans = max(ans, 0);
	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int k, s, ans = 0;
  scanf("%d %d", &k, &s);
  for(int x = 0; x <= k; x++){
    for(int y = 0; y <= k; y++){
      int z = s - x - y;
      if(0 <= z && z <= k) ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1668
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;




int main(){
    int n;cin >> n;
    vector<LL> p(n);
    map<LL,LL> ma;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        ma[-p[i]] = i;
    }
    vector<P> aa(n),bb(n);
    set<LL> st,sf;
    for(auto q:ma){
        auto t = st.upper_bound(q.sc);
        if(t == st.end()){
            bb[q.sc] = mp(n,n);
        }
        else{
        auto k = st.upper_bound(*t);
            if(k == st.end()){
                bb[q.sc] = mp(*t,n);
            }
            else{
                bb[q.sc] = mp(*t,*k);
            }

        }
        st.insert(q.sc);
        auto l = sf.upper_bound(-q.sc);
        if(l == sf.end()){
            aa[q.sc] = mp(-1,-1);
        }
        else{
            auto k = sf.upper_bound(*l);
            if(k == sf.end()){
                aa[q.sc] = mp(-1,-*l);
            }
            else{
                aa[q.sc] = mp(-*k,-*l);
            }
        }
        sf.insert(-q.sc);
    }
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        ans += p[i] * ((i - aa[i].sc) * (bb[i].sc - bb[i].fs) + (aa[i].sc - aa[i].fs) * (bb[i].fs - i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19840
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

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

int main() {
  ll i, j, k;
  
  ll K;
  cin >> K;
  
  ll ans=0;
  for(i=1; i<=K; i++) {
    for(j=1; j<=K; j++) {
      for(k=1; k<=K; k++) {
        ans+=gcd(i, gcd(j, k));
      }
    }
  }
  
  pt(ans);
  
}




Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[] = {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<<a[k-1]<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

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

    int N, M;
    cin >> N >> M;
    int A[N][M];
    int K[M];
    vector<int> B(M + 1, 0);
    REP(i, N) {
        cin >> K[i];
        REP(j, K[i]) {
            cin >> A[i][j];
            B[A[i][j]]++;
        }
    }

    int ans = 0;

    REP(i, M + 1) {
        if (B[i] == N)
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7 + 1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

map<string, string> mp, mpg,mpa;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	vi v(n);
	ll even = 0, odd = 0;
	REP(i, n)
	{
		cin >> v[i];
		if (v[i] % 2 == 0) {
			even++;
		} else {
			odd++;
		}
	}
	if (n == 1) {
		if (v[0] % 2 == 0) {
			cout << 1 << endl;
			return 0;
		} else {
			cout << 2 << endl;
			return 0;
		}
	}
	ll minus = 1;
	REP(i, v.size())
	{
		if (v[i] % 2 == 0) {
			minus *= 2;
		} else {
			minus *= 1;
		}
	}
	ans = pow(3, v.size()) - minus;
	cout << ans << endl;
}

Measured memory_bytes: 640
import math
D, G = map(int, input().split())
p = {}
c = {}
for i in range(D):
	p[i], c[i] = map(int, input().split())
ans = 9999
for i in range(1 << D):
	rest_max = -1
	sum = 0
	n = 0
	for j in range(D):
		if (i >> j) & 1 == 1:
			sum = sum + p[j] * (j + 1) * 100 + c[j]
			n = n + p[j]
		else:
			rest_max = j
	if rest_max == -1:
		ans = min(ans, n)
		continue
	if sum + (p[rest_max] - 1) * (rest_max + 1) * 100 < G:
		continue
	n = n + max(math.ceil((G - sum) / 100 / (rest_max + 1)), 0)
	ans = min(ans, n)
	#print(i, ans)
print(ans)

Measured memory_bytes: 40944
#include<stdio.h>

int main(){
	
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	
	return 0;
}



Measured memory_bytes: 2000