akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

class PQ_COMP{
public:
  bool operator()(const tuple<int,int,int>&q1,const tuple<int,int,int>&q2)
  {
    if(get<0>(q1) == get<0>(q2)){
      return get<1>(q1)>get<1>(q2);
    }
    else{
      return get<0>(q1)<get<0>(q2);
    }
  }
};

int main()
{
  int n,q;
  cin >> n >> q;
  vector<int>v1(n,0);
  vector<int>v2(n,0);
  priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,PQ_COMP>pq;

  for(int i=0;i<n;i++)
  {
    pq.push(make_tuple(0,i,0));
  }
  for(int i=0;i<q;i++){
    int id,num;
    cin >> id >> num;
    id--;
    v1[id]+=num;
    v2[id]+=1;
    pq.push(make_tuple(v1[id],id,v2[id]));
    while(true){
      auto buf=pq.top();
      id=get<1>(buf);
      if(get<2>(buf)!=v2[id]){
        pq.pop();
        continue;
      }
      int &o1=get<1>(buf);
      int &o2=get<0>(buf);
      cout << o1+1 << " " << o2 << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 35160
#include <stdio.h>

long long fac_mod(long long n){
  long long x = 1;
  while(n > 0){
    x *= n--;
    x %= 1000000007;
  }

  return x;
}

int
main(int argc, char *argv[])
{
  long long n, m, ans; 
  scanf("%lld %lld", &n, &m);
  if(n - m == 1 || n - m == -1){
    ans = fac_mod(n) * fac_mod(m) % 1000000007;
  }
  else if(n == m) ans = 2 * fac_mod(n) * fac_mod(m) % 1000000007;
  else ans = 0;

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

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {

  int H, W;

  cin >> H >> W;

  char mat[102][102];

  REP(i, H){
    REP(j, W){
      cin >> mat[i][j];
    }
  }

  vector<int> ig_x, ig_y;
  bool isB = true;
  REP(i, H){
    REP(j, W){
      if (mat[i][j] != '.') {
        isB = false;
        break;
      }
    }
    if (isB) ig_x.push_back(i);
    isB = true;
  }

  REP(j, W){
    REP(i, H){
      if (mat[i][j] != '.') {
        isB = false;
        break;
      }
    }
    if (isB) ig_y.push_back(j);
    isB = true;
  }

  // for (auto iter = ig_x.begin(); iter != ig_x.end(); iter++){
  //   cout << *iter;
  // }

  if (ig_x.size() == 0) ig_x.push_back(1000);
  if (ig_y.size() == 0) ig_y.push_back(1000);

  int k = 0;
  int l = 0;
  REP(i, H){
    if (ig_x[k] == i){
      k++;
    } else {
      REP(j, W){
        if (ig_y[l] == j){
          l++;
        }else {
          cout << mat[i][j];
        }
      }
      l = 0;
      cout << endl;
    }
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  vector<tuple<int, int, int>> absum;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    absum.emplace_back(a + b, a, b);
  }
  sort(absum.rbegin(), absum.rend());
  i64 ans = 0;
  rep(i, n) {
    int _, a, b;
    tie(_, a, b) = absum[i];
    if (i % 2 == 0) ans += a;
    if (i % 2 == 1) ans -= b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1912
import math
a,b,h,m=map(int,input().split())
angle=min(max(30*h+m/2,6*m)-min(30*h+m/2,6*m),360-(max(30*h+m/2,6*m)-min(30*h+m/2,6*m)))

cos=math.cos(math.radians(angle))
ans=math.sqrt(a**2+b**2-2*a*b*cos)
print(ans)

Measured memory_bytes: 9516
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
          Scanner scn= new Scanner(System.in);
          int k = scn.nextInt();
          int a=scn.nextInt();
          int b=scn.nextInt();
          if(a%k==0 || b%k==0 || (b/k-a/k)>0){
        	  System.out.println("OK");
        	 
          }else{
        	  System.out.println("NG");
          }
         
	}

}

Measured memory_bytes: 35708
N, M = map(int, input().split())

G = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    G[x].append(y)

inord = [0 for i in range(N)]
stack = []
for u in range(N):
    for v in G[u]:
        inord[v] += 1

for i in range(N):
    if inord[i] == 0:
        stack.append(i)

ans = []
while len(stack):
    u = stack.pop()
    ans.append(u)
    for v in G[u]:
        inord[v] -= 1
        if inord[v] == 0:
            stack.append(v)

#ansはtopological_sortされている

#dp[i]:i番目にたどり着くまでの最長経路
dp = [0 for i in range(N)]
for u in ans:
    for v in G[u]:
        dp[v] = max(dp[u]+1, dp[v])

ret = 0
for i in range(N):
    ret = max(ret, dp[i])
print(ret)

Measured memory_bytes: 23588
import itertools,math
n=int(input())
t=[list(map(int,input().split())) for i in range(n)]
s=[i for i in range(n)]
l=list(itertools.permutations(s))
tmp=[]
for i in l:
    dis=0
    for j in range(n-1):
        x1=t[i[j+1]][0]
        x2=t[i[j]][0]
        y1=t[i[j+1]][1]
        y2=t[i[j]][1]
        dis+=((x2-x1)**2+(y2-y1)**2)**(1/2)
    tmp.append(dis)
print(sum(tmp)/math.factorial(n))

Measured memory_bytes: 47964
#include<bits/stdc++.h>
#include<random>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin>>N;
	vector<ll> x(N);
	vector<ll> y(N);
	vector<ll> h(N);
	REP(i,N) cin>>x[i]>>y[i]>>h[i];
	FOR(cx,0,101) FOR(cy,0,101) {
		set<ll> s;
		ll mini=INF*INF;
		REP(i,N) {
			ll dist=abs(x[i]-cx)+abs(y[i]-cy);
			if(h[i]==0) {
				mini=min(dist,mini);
				continue;
			}
			s.insert(dist+h[i]);
		}
		if(s.size()==1&&*s.begin()<=mini) {
			cout<<cx<<" "<<cy<<" "<<*s.begin()<<endl;
			return 0;
		} else if(s.size()==0) {
			if(mini>0) {
			cout<<cx<<" "<<cy<<" "<<mini<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=1e9+7;
const ll ms=1e6+5;
const ll inf=-1e17;


int ar[ms];
int pr[ms];

int main()
{
    idfc;

    int n;
    cin>>n;
    int i;
    pr[0]=0;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
        pr[i]=__gcd(pr[i-1],ar[i]);
    }
    int p=0;
    int ans=1;
    for(i=n;i>=1;i--)
    {
        ans=max(ans,__gcd(p,pr[i-1]));
        p=__gcd(p,ar[i]);
    }
    cout<<ans;





    return 0;
}

Measured memory_bytes: 4348
import java.util.Scanner;
import java.util.ArrayList;

// ALDS1_2_D
public class Main {
	static int cnt;
	public static void insertionSort(int[] array, int n, int g) {
		int v, j;
		for (int i = g; i < n; i++) {
			v = array[i]; j = i - g;
			while (j >= 0 && array[j] > v) {
				array[j+g] = array[j];
				j = j -g;
				cnt++;
				array[j+g] = v;
			}
		}
	}
	
	public static void shellSort(int[] array, int n) {
		cnt = 0;
		int m = 0;
		ArrayList<Integer> G = new ArrayList<Integer>();
		
		for (int i = 1; i < n + 1; i = 3*i+1) {
			G.add(i);
			m++;
		}
		for (int i = m - 1; i >= 0; i--) {
			insertionSort(array, n, G.get(i));
		}
		
		System.out.println(m);
		for (int i = m - 1; i >= 0; i--) {
			System.out.print(G.get(i));
			if (i > 0) System.out.print(" ");
		}
		System.out.println();
		System.out.println(cnt);
		for (int v : array)
			System.out.println(v);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		shellSort(array, n);
	}
}



Measured memory_bytes: 299080
#include <iostream>
#include <cstdlib>

int main()
{
    int a, b;
    std::cin >> a >> b;
    if (a > 8) {
        std::cout << ":(" << std::endl;
        exit(0);
    } else if (b > 8) {
        std::cout << ":(" << std::endl;
        exit(0);
    }
    std::cout << "Yay!" << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;

//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    vector<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;
    k--;
    cout << a[k] << endl;
    
    return 0;
}

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

int W,H,x,y,r;

int main(){
    cin>>W>>H>>x>>y>>r;
    
    if(y+r > H || x+r > W || y-r < 0 || x-r < 0){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define LL long long
#define Max 100005
#define Mod 1e9+7
const LL mod=1e9+7;
const LL inf=0x3f3f3f3f;
using namespace std;
map<int,string> m;
int dp[105][5][5][5];
bool check(int a,int b,int c,int d)
{

    if(m[a]+m[c]+m[b]=="AGC")
        return false;
    if(m[a]+m[b]+m[c]=="AGC")
        return false;
    if(m[a]+m[c]+m[d]=="AGC")
        return false;
    if(m[a]+m[b]+m[d]=="AGC")
        return false;
    if(m[b]+m[c]+m[d]=="AGC")
        return false;
    if(m[b]+m[d]+m[c]=="AGC")
        return false;
    if(m[b]+m[a]+m[c]=="AGC")
        return false;
    if(m[c]+m[b]+m[d]=="AGC")
        return false;
    return true;
}
int main()
{
    int n;
    scanf("%d",&n);
    dp[0][0][0][0]=1;
    m[0]='W',m[1]='A',m[2]='C',m[3]='G',m[4]='T';
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=4; j++)
        {
            for(int k=0; k<=4; k++)
            {
                for(int l=0; l<=4; l++)
                {
                    for(int m=0; m<=4; m++)
                    {
                        if(check(m,l,k,j))
                            dp[i][j][k][l]=(dp[i][j][k][l]+dp[i-1][k][l][m])%mod;
                    }
                }
            }
        }
    }
    int ans=0;
    for(int i=1;i<=4;i++){
        for(int j=1;j<=4;j++){
            for(int k=1;k<=4;k++){
                ans=(ans+dp[n][i][j][k])%mod;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int maxn = 1e5+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}



main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    ll a, b, c; cin>>a>>b>>c;
    cout<<(c/a)*b<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m;
    cin>>n>>m;
    UnionFind tree(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        tree.unite(x,y);
    }
    int ans=0;
    rep(i,n){
        if(tree.par[i]==i)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 768
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include<stack>
#include<queue>
using namespace std;

 
int main(){
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 != m2){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
use std::cmp;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut a: Vec<u64> = sc.vec(n + 1);
    let b: Vec<u64> = sc.vec(n);
    let mut ans = 0;
    for i in 0..n {
        let prev = cmp::min(a[i], b[i]);
        ans += prev;
        let remain = b[i] - prev;

        let next = cmp::min(remain, a[i + 1]);
        a[i + 1] -= next;
        ans += next;
    }
    println!("{}", ans);
}

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')
            .take_while(|&b| b != b' ' && b != b'\n')
            .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: 6396
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG


int main() {
  string S, T;
  cin >> S >> T;
  
  ll ans = 0;
  
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));

  for(ll i=0; i < S.size(); i++){
    if(S.at(i) != T.at(i)){
      ans++;
    }
  }
  
  cout << ans << endl;

  return 0;
}


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

const int N = 1e5;
int dp[N + 5];
int arr[N + 5];

int main() {
	
	int n;
	cin>>n;
	for(int i = 1;i <= n;i++) {
		dp[i] = 1e9;
		cin>>arr[i];
	}
	dp[1] = 0;
	dp[0] = 1e9;
	for(int i = 2;i <= n;i++) {
		dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
S = input()
T = input()
ans = float('inf')

for i in range(len(S) - len(T) + 1):
    s = list(S[i:i + len(T)])
    t = list(T)
    count = 0
    for j in range(len(T)):
        if s[j] != t[j]:
            count += 1
    ans = min(ans, count)

print(ans)

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

using namespace std;

typedef long long ll;

const int N = (int)1e6 + 5;

void scans(string &s) {
  char b[N];
  scanf("%s", &b);
  s = b;
  return;
}

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);
  printf("%d", max(a * b, c * d));
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>



using namespace std;


int main() {
	int a, b;
	cin >> a >> b;
	if(b >= a) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct XY
{
	int x;
	int y;
};
int main ()
{
	string a;
	getline(cin,a);
	while(a!=".")
	{
		bool ok = false;
		stack<int> x;
		for(int i=0;i<a.size();i++)
		{
			if(a[i]=='(')x.push(1);
			if(a[i]==')')
			{
				if(x.empty())
				{
					ok =true;
				}
				else if(x.top()==1)
					x.pop();
				else 
					ok = true;
			}
			if(a[i]=='[')x.push(2);
			if(a[i]==']')
			{
				
				if(x.empty())
				{
					
					ok = true;
				}else 
				if(x.top()==2)
					x.pop();
				else ok = true;
			}
		}
		if(x.empty()&&!ok)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
		getline(cin,a);
	}
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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(){
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
string divide[4] = {"dream", "dreamer", "erase", "eraser"};
int main(){
  string S;
  cin >> S;
  reverse(S.begin (), S.end());
  for(int i = 0; i < 4; i++)reverse(divide[i].begin(), divide[i].end());

  bool c =true;
  for(int i =0; i < S.size();){
    bool b = false;
    for(int j = 0; j < 4; j++){
      string d = divide[j];
      if(S.substr(i,d.size()) == d){
        b = true;
        i+= d.size();
      }
      }
      if(b == false){
        c = false;
        break;
      }
    }
    if(c == true) cout <<"YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int[] v = new int[25000];
        for(int i = 0;i < 25000;i++){
            v[i] = 1;
        }
        int p = 3;
        while(true){
            if(p*p > 50000){
                break;
            }else{
                if(v[(p-1)/2] == 0){
                    p += 2;
                }else{
                    int t = p*p;
                    while(t < 50000){
                        v[(t-1)/2] = 0;
                        t += 2*p;
                    }
                    p += 2;
                }
            }
        }
		while(scan.hasNext()){
			int n = scan.nextInt();
			if(n == 0){
				break;
			}else if(n == 4){
				System.out.println(1);
				continue;
			}else if(n%2 != 0){
				if(v[(n-3)/2] == 1){
					System.out.println(1);
				}else{
					System.out.println(0);
				}
				continue;
			}
			int count = 0;
			for(int i = 1;i <= (n/2-1)/2;i++){
				if(v[i] == 1 && v[n/2-i-1] == 1){
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 32984
h, w = [ int(i) for i in input().split()]
grid = [list(input()) for j in range(h)]
isOkColumn = [ 0 for i in range(w)]
isOkRow = [0 for i in range(h)]

for r in range(h):
    if '#' in grid[r]:
        isOkRow[r] = 1
    for c in range(w):
        if grid[r][c] == '#':
            isOkColumn[c] = 1

for r in range(h):
    if isOkRow[r] == 1:
        r_g = ''
        for c in range(w):
            if isOkRow[r] == 1 and isOkColumn[c] == 1:
                r_g += grid[r][c]
        print(r_g)


Measured memory_bytes: 3188
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<cmath>
#include<ctime>
#include<complex>

using namespace std;

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


int main(){

  while(true){

  int a,b,n,x,y;
  cin >> a >> b;
  if(a==0 && b==0) break;

  int Road[b+1][a+1];
  rep(i,b+1) rep(j,a+1) Road[i][j]=0;
  Road[1][1]=1;

  cin >> n;

  rep(i,n){
	 cin >> x >> y;
	 Road[y][x]=-1;
  }

	 REP(i,1,b){
	 REP(j,1,a){
	 if(Road[i][j]!=-1 && (i!=1 || j!=1)){
	 if(Road[i][j-1]!=-1 && Road[i-1][j]!=-1) Road[i][j]=Road[i][j-1]+Road[i-1][j];
	 if(Road[i][j-1]!=-1 && Road[i-1][j]==-1) Road[i][j]=Road[i][j-1];
	 if(Road[i][j-1]==-1 && Road[i-1][j]!=-1) Road[i][j]=Road[i-1][j];

	 }
	 }
	 }

	 cout << Road[b][a] << endl;
	 
  }

    return 0;

}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll N;
    cin>>N;
    vector<ll> A(N),fixed(N);
    rep(i,N) {
        cin>>A.at(i);
        fixed.at(i)=A.at(i);
    }
    
    map<ll,ll> mp;
    ll ans=0;

    sort(ALLOF(fixed));
    ll now=0,kosu=0;
    rep(i,N){
        if(fixed.at(i)==now) kosu+=1;
        else {
            mp[now]=kosu;
            ans+=kosu*(kosu-1)/2;
            now=fixed.at(i);
            kosu=1;
        }
        
    }
    mp[now]=kosu;
    ans+=kosu*(kosu-1)/2;
    
    rep(i,N){
        ll value=mp[A.at(i)];
        cout<<ans-value+1<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 12672
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
ans=0
sb=0
fa=0
sbfa=0
for i in range(n):
    ts=S()
    if ts[0]=="B" and ts[-1]!="A":
        sb+=1
    elif ts[0]!="B" and ts[-1]=="A":
        fa+=1
    elif ts[0]=="B" and ts[-1]=="A":
        sbfa+=1
    for i in range(len(ts)-1):
        if ts[i]=="A" and ts[i+1]=="B":
            ans+=1
    
p=min(fa,sb,sbfa)
ans+=2*p
if p>0:
    ans+=sbfa-p+min(max(0,fa-p),max(0,sb-p))
else:
    if sbfa==0:
        ans+=min(max(0,fa-p),max(0,sb-p))
    elif sb==0:
        if fa>sbfa:
            ans+=sbfa
        else:
            ans+=sbfa-1+min(1,fa)
    elif fa==0:
        if sb>sbfa:
            ans+=sbfa
        else:
            ans+=sbfa-1+min(1,sb)   
print(ans)

Measured memory_bytes: 3064
class Program
{
    static void Main(string[] args)
    {
        string[] str = System.Console.ReadLine().Split(' '); //700 600 680
        var a = int.Parse(str[0]); //700
        var b = int.Parse(str[1]); //600
        var c = int.Parse(str[2]); //780
        if (a < b)
        {
            if (b < c)
            {
                System.Console.Write(a + b);
            }
            else
            {
                System.Console.Write(a + c);
            }
        }
        else
        {
            if (a < c)
            {
                System.Console.Write(b + a);
            }
            else
            {
                System.Console.Write(b + c);
            }
        }
    }
}

Measured memory_bytes: 11092
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll a,b,c,d;

int main() {
  INCANT;
  cin >> a >> b >> c >> d;
  ll ans = max(a*c, b*d);
  ll ans2 = max(a*d, b*c);
  cout << max(ans, ans2) << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    long count = 0;
    for (long i = k; i < n + 2; i++){
        long min = (i * (i - 1)) / 2;
        long max = (n * i) + i - ((i * (i + 1)) / 2);
        count += max - min + 1;
    }
    cout << count % 1000000007 << std::endl;
    return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

const vector<int> Update(const int N, const vector<int> &as)
{
    vector<int> updated(N, 0);
    vector<int> diffs(N + 1, 0);
    for (int i = 0; i < N; ++i)
    {
        int ai = as[i];
        ++diffs[max(0, i - ai)];
        --diffs[min(N, i + ai + 1)];
    }
    int sum = 0;
    for (int i = 0; i < N; ++i)
    {
        sum += diffs[i];
        updated[i] = sum;
    }
    return updated;
}

const bool IsAll(const int N, const vector<int> &as)
{
    return count(as.begin(), as.end(), N) == N;
}

int main()
{
    // 単純にシミュレーション
    // K~20回程度で全体が照らされるようになる
    int N, K; cin >> N >> K;
    vector<int> as(N); for (auto &ai : as) cin >> ai;
    for (int i = 0; i < K; ++i)
    {
        as = Update(N, as);
        if (IsAll(N, as)) break;
    }
    for (int i = 0; i < N - 1; ++i) cout << as[i] << ' ';
    cout << as.back() << endl;
}


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


int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    while((a > 0) && (c > 0)){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        } 

        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}



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

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)


class BPalindromicNumbers {
public:
	void solve(std::istream& in, std::ostream& out) {
    int a,b;
    in >> a >> b;
    int cnt = 0;
    FOR(i, a, b + 1){
      string s = to_string(i);
      string sub1 = s.substr(0, 2);
      string sub2 = s.substr(s.length() - 2, 2);
      swap(sub2[0], sub2[1]);
      if(sub1 == sub2){
        cnt++;
      }
    }
    out << cnt << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	BPalindromicNumbers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

typedef pair<int, int> P;

bool sort_by_b(P &num1, P &num2) {
  return num1.second < num2.second;
}


int main(){
  int N, M;
  cin >> N >> M;
  vector<P> requests(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    requests[i].first = a;
    requests[i].second = b;
  }
  sort(requests.begin(), requests.end(), sort_by_b);

  int cutting = requests[0].second - 1;
  int ans = 1;
  for (int i = 1; i < M; i++) {
    if (cutting < requests[i].first) {
      cutting = requests[i].second - 1;
      ans ++;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
point_a = 0
point_b = 0
for i in range(N):
    a,b = input().split()
    if a > b:
        point_a+=3
    elif a < b:
        point_b+=3
    else:
        point_a+=1
        point_b+=1
print("{} {}".format(point_a,point_b))


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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i=0;i<N;i++){
        cin >> p.at(i);
    }

    sort(p.begin(), p.end());
    
    int ans=0;
    for(int i=0;i<K;i++){
        ans = ans + p.at(i);

    }

    cout << ans << endl;

}

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

class UnionFind {
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) std::swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
private:
	std::vector<int> data;
};

int n, m;
int e[100005][2];
int main()
{
	std::cin >> n >> m;

	UnionFind uf(n);

	for (int i = 0; i < m; ++i) {
		int a, b;
		std::cin >> a >> b;
		e[i][0] = a - 1;
		e[i][1] = b - 1;
	}

	long long ans = static_cast<long long>(n) * static_cast<long long>(n - 1) / 2;
	long long res[100005];
	for (int i = m - 1; i >= 0; --i) {
		res[i] = ans;
		auto con = uf.findSet(e[i][0], e[i][1]);
		if (!con)
			ans = ans - static_cast<long long>(uf.size(e[i][0]))*static_cast<long long>(uf.size(e[i][1]));

		uf.unionSet(e[i][0], e[i][1]);
	}

	for (int i = 0; i < m; ++i)
		std::cout << res[i] << std::endl;
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;

int main() {
  int N; cin >> N;
  int A[100010],B[100010];
  for ( int i = 0; i< N; i++ ) cin >> A[i] >> B[i];
  ll ans = 0;
  for ( int i = N-1; i >= 0 ; i-- ) {
    if ( A[i] == 0 ) continue;
    ll keta = (ans+A[i]-1)/B[i];
    ans += B[i]*(keta+1)-A[i]-ans;
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <ios>
#include <iomanip>
#include <utility>
#include <functional>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
#define rem(i,n,x) for(int i=n;i>x;i--)
#define SORT(x) sort(x.begin(),x.end())
#define rev(x) reverse(x.begin(),x.end())
#define all(x) x.begin(),x.end()
#define pb push_back
#define setp(x) setprecision(x)
using ll = long long;
using ull = unsigned long long;

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

	int ans;
	ans = n % (d * 2 + 1);
	if (ans == 0) {
		cout << n / (d * 2 + 1) << endl;
	}
	else {
		cout << n / (d * 2 + 1) + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
// メイン
int main()
{
	int N;
	cin >> N;
	vector<int> A(100000 + 2, 0);
	REP(i, N) {
		int a;
		cin >> a;
		A[a]++;
		A[a + 1]++;
		if (0 < a) {
			A[a - 1]++;
		}
	};
	sort(ALL(A));
	reverse(ALL(A));
	cout << A[0] << endl;
	return 0;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var N, M int
	var s string
	fmt.Scan(&N)
	sm := make(map[string]int)
	for i := 0; i < N; i++ {
		fmt.Scan(&s)
		sm[s]++
	}
	fmt.Scan(&M)
	tm := make(map[string]int)
	for i := 0; i < M; i++ {
		fmt.Scan(&s)
		tm[s]++
	}
	max := 0
	for sk, sv := range sm {
		d := sv - tm[sk]
		if d > max {
			max = d
		}
	}
	fmt.Println(max)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {

  ll n;
  cin >> n;

  vector<ll> ans(n + 1);

  ll root2n = sqrt(2*n) + 1;

  for(ll p = 1; p < root2n; p++) {
    
    for(ll q = 1; q <= p; q++) {

      for(ll r = 1; r <= q; r++) {

        ll func = p * p + q * q + r * r + q * p + q * r + r * p;
        // if(func % 2 != 0) continue;
        // else{
        //   func = func / 2;
        // }

        ll count = 0;
        if(p == q && p == r) count = 1;
        else if(p != q && p != r && r != q) count = 6;
        else {
          count = 3;
        }

        if(func <= n) {
          ans.at(func)+= count ;
          //cout << p << ' ' << q << ' ' << r << ' ' << func <<endl;
        }
      }
    }
  }

  rep(i,n + 1) {
    if(i == 0) continue;
    cout << ans.at(i) << endl;
  }

}



Measured memory_bytes: 3612
a,b = (int(i) for i in input().split())
def gcd(a,b):
    if a%b: return gcd(b,a%b)
    else: return b
g = gcd(a,b)
num,ans = g,1
for i in range(2,int(g**0.5)+1):
    if num%i==0:
        ans+=1
        while num%i==0: num//=i
if num!=1: ans+=1
print(ans)

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

int main() {
	int A,B;
	cin >> A >> B;
  cout << (A-1)*(B-1) << endl;
}

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

using namespace std;


int main(){

	int n;
	string ID;
	int m;
	int in;
	int wa;
	int dp[2][11]={0};
	int ans;
	vector<int> a;


	cin>>n;
	cin>>ID;
	cin>>m;
	while(m--){
		cin>>in;
		a.push_back(in);
	}

	dp[0][0]=1;

	for(int i=1;i<=ID.size();i++){
		for(int j=10;j>=0;j--){
			if(dp[0][j]>0){
				if(ID[ID.size()-i]=='*'){
					for(int k=0;k<a.size();k++){
						if(i%2==0) wa=a[k]*2;
						else wa=a[k];
						if(wa>=10) wa=wa/10+wa%10;
						dp[1][(j+wa)%10]+=dp[0][j];
					}
				}
				else{
					if(i%2==0) wa=(ID[ID.size()-i]-'0')*2;
					else wa=ID[ID.size()-i]-'0';
					if(wa>=10) wa=wa/10+wa%10;
					dp[1][(j+wa)%10]+=dp[0][j];
				}
			}
		}
		for(int j=10;j>=0;j--){
			dp[0][j]=dp[1][j];
			dp[1][j]=0;
		}
	}

	cout<<dp[0][0]<<endl;

	return 0;
}

Measured memory_bytes: 1356
import Control.Applicative

import Data.Char
    (toLower)

type Problem = String

type Result = [Int]

solve :: Problem -> Result

solve text
    = map (\char -> length $ filter (char ==) lower) chars where
        lower = map toLower text
        chars = ['a'..'z']

output :: [Int] -> String

output xs
    = concat $ zipWith (\x char -> [char] ++ " : " ++ show x ++ "\n") xs ['a'..'z']

input :: IO String

input
    = getContents

main :: IO ()

main
    = putStr.output =<< solve <$> input

Measured memory_bytes: 3780
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 1e6;


vector<vii> adj;
vector<bool> seen;
vii ts;

void dfs(int curr) {
    seen[curr] = true;
    for (int node : adj[curr]) {
        if (seen[node]) continue;
        dfs(node);
    }
    ts.push_back(curr);
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    int n, m;
    cin >> n >> m;
    adj.assign(n, vii());
    seen.assign(n, false);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        adj[a].push_back(b);
    }
    for (int i = 0; i < n; i++) {
        if (!seen[i]) 
            dfs(i);
    }
    reverse(ts.begin(), ts.end());
        
    vii dp(n, 0);
    for (int curr : ts) {
        for (int node : adj[curr]) {
            dp[node] = max(dp[curr] + 1, dp[node]);
        }
    }
    
    cout << *max_element(dp.begin(), dp.end()) << '\n';
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    string a, b;
    cin >> a >> b;
    a += b;

    ll c = stoll(a);

    bool ok = false;
    for (ll i = 1; i * i <= c; i++) {
        if (i * i == c) {
            ok = true;
        }
    }

    cout << (ok ? "Yes\n" : "No\n");
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string S;
int ans;

int main()
{
	in >> S;
	ans = 700;
	if (S[0] == 'o') ans += 100;
	if (S[1] == 'o') ans += 100;
	if (S[2] == 'o') ans += 100;
	out << ans << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
const ull big = 1000000000000000000;

int main(){FIN

    ull n;cin>>n;
    ull ans=1;
    vector<ull> a(n);
    REP(i,n) cin>>a[i];
    VSORT(a);
    if(a[0]==0){
        cout<<0<<endl;
        return 0;
    }

    ll count=0;
    REP(i,n){
        count+=log10(a[i]);
    }
    if(count>=19){
        cout<<-1<<endl;
        return 0;
    }

    REP(i,n){

        ans *= a[i];
        if (i>0 && log10(a[i])+log10(a[i-1]) > 18){
            cout<<-1<<endl;
            return 0;
        }
        if (a[i]>big){
            cout<<-1<<endl;
            return 0;
        }
        if(ans>big || ans<0){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int k,a,b;
	string str = "NG";

	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			str = "OK";
			break;
		}
	}
	cout << str;
}


Measured memory_bytes: 3628
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, K = read_int()
S = read_str()

def solve():
    return S[:K-1] + S[K-1].lower() + S[K:]

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3948
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            long K = long.Parse(Console.ReadLine());

            bool l = false;
            if(s[0] == s[s.Length-1])
            {
                l = true;
            }

            long ans = 0;
            if (l)
            {
                // 先頭の連続
                int head = 1;
                while (head < s.Length && s[head - 1] == s[head])
                {
                    head++;
                }

                int tail = s.Length - 1;
                while (tail > head && s[tail - 1] == s[tail])
                {
                    tail--;
                }

                // 全部同じ場合
                if(head == tail + 1)
                {
                    ans = s.Length * K / 2;
                }
                else
                {
                    int cont = 1;
                    for (int i = head; i < tail; i++)
                    {
                        if (s[i - 1] == s[i])
                        {
                            cont++;
                        }
                        else
                        {
                            ans += cont / 2;
                            cont = 1;
                        }
                    }
                    ans += cont / 2;
                    ans *= K;

                    ans += head / 2;
                    ans += (s.Length - tail) / 2;
                    ans += (head + s.Length - tail) / 2 * (K - 1);
                }
            }
            else
            {
                long cont = 1;

                for (int i = 1; i < s.Length; i++)
                {
                    if(s[i-1] == s[i])
                    {
                        cont++;
                    }
                    else
                    {
                        ans += cont / 2;
                        cont = 1;
                    }
                }
                ans += cont / 2;

                ans *= K;
            }

            Console.WriteLine(ans);
        }
    }
}



Measured memory_bytes: 11092
#include <cstdio>
#include <algorithm>

using namespace std;

#define INF 1e9
#define FOR(i,a,b) for(int i = a ; i < b ; i++)

int main(){
  int N,a[100][100];
  int ans = -INF;

  scanf("%d" ,&N);
  FOR(i,0,N){
    FOR(j,0,N){
      scanf("%d" ,&a[i][j]);
      ans = max(ans,a[i][j]);
    }
  }

  FOR(i,0,N){
    int b[100] = {0};
    FOR(j,i,N){
      int sum = 0;
      FOR(k,0,N){
	b[k] += a[j][k];
	sum = max(sum + b[k] ,0);
	if(sum) ans = max(ans,sum);
      }
    }
  }

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

  return 0;
}

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


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

    if(s=="Sunny")
    {
        cout<<"Cloudy";
    }
    if(s=="Cloudy")
    {
        cout<<"Rainy";
    }
    if(s=="Rainy")
    {
        cout<<"Sunny";
    }
    return 0;
}


Measured memory_bytes: 256
dp = Array.new(1001){Array.new(10){0}}
dp[0][0] = 1

0.upto(100){|i|
  1000.downto(i){|j|
    9.downto(1){|k|
      dp[j][k] += dp[j-i][k-1] 
    }
  }
}

readlines.each{|line|
  n, s = line.split.map(&:to_i)
  break if n == 0 && s == 0
  puts dp[s][n]
}

Measured memory_bytes: 8820
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = 0;
    rep(si,h)rep(sj,w) {
        if(s[si][sj] == '#') continue;
        vector<vector<int>> dist(h, vector<int>(w, INF));
        queue<P> q;
        auto update = [&](int i, int j, int x) {
            if (dist[i][j] != INF) return;
            dist[i][j] = x;
            q.push(P(i,j));
        };
        update(si, sj,0);
        while (!q.empty()) {
            int i = q.front().first;
            int j = q.front().second; q.pop();
            rep(dir, 4) {
                int ni = i+di[dir], nj= j+dj[dir];
                if (ni<0||ni>=h||nj<0||nj>=w) continue;
                if (s[ni][nj] == '#') continue;
                update(ni, nj, dist[i][j]+1);
            }
        }
        rep(i,h)rep(j,w) {
            if (dist[i][j] == INF) continue;
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256