akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int N;
vector<int> a, s;
int dp[400][400];
int sum(int l, int r) {
    return s[r] - (l > 0 ? s[l - 1] : 0);
}
// [l, r]
int rec(int l, int r) {
    auto &DP = dp[l][r];
    if (DP != -1) return DP;

    if (l == r) return DP = 0;

    int ret = INF;
    REPF(i, l, r) {
        int tmp = 0;
        tmp = (rec(l, i) + sum(l, i)) + (rec(i + 1, r) + sum(i + 1, r));
        chmin(ret, tmp);
    }
    return DP = ret;
}
signed main() {
    REP(i, 400) REP(j, 400) dp[i][j] = -1;

    int N;
    cin >> N;
    a.resize(N);
    cin >> a;
    s = a;
    PSUM(s);

    cout << rec(0, N - 1) << endl;
    return (0^_^0);
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    string S;
    cin >> S;
    set<char> S1;
    rep(i,S.size()){
    S1.insert(S[i]);
    }
    if(S1.size()==2){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

#define ALL(obj) (obj).begin(), (obj).end()
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
#define pb push_back
#define INF 100100100
//const int INF = 100100100;
const int MOD = (int) 1e9 + 7;
const double EPS = 1e-9;

using vi = vector<int>;

int main()
{
  int N;
  cin >> N;
  // vector<int> d;
  map<int, int> d;
  int ans = 0;
  rep(i,N) {
    int tmp;
    cin >> tmp;
    if (d.count(tmp)) {
    } else {
      ans++;
      d[tmp] = 1;
    }
    //if (auto itr = d.find(tmp); itr != end(d)) {
    //} else {
    //  d[tmp] = 1;
    //  ans++;
    //}

  }
  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define int long long
#define N 3002
using namespace std;
const int mod=1000000007;
int n,q,i,j,a[N],f[N][N],x[N],y[N],p,inv,ans;
int read()
{
	char c=getchar();
	int w=0;
	while(c<'0'||c>'9') c=getchar();
	while(c<='9'&&c>='0'){
		w=w*10+c-'0';
		c=getchar();
	}
	return w;
}
int poww(int a,int b)
{
	int ans=1,base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod;
		b>>=1;
	}
	return ans;
}
signed main()
{
	n=read();q=read();
	p=poww(2,q),inv=poww(2,mod-2);
	for(i=1;i<=n;i++) a[i]=read();
	for(i=1;i<=q;i++) x[i]=read(),y[i]=read();
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++) f[i][j]=(a[i]>a[j]);
	}
	for(i=1;i<=q;i++){
		f[x[i]][y[i]]=f[y[i]][x[i]]=(f[x[i]][y[i]]+f[y[i]][x[i]])%mod*inv%mod;
		for(j=1;j<=n;j++){
			if(j==x[i]||j==y[i]) continue;
			f[x[i]][j]=f[y[i]][j]=(f[x[i]][j]+f[y[i]][j])%mod*inv%mod;
			f[j][x[i]]=f[j][y[i]]=(f[j][x[i]]+f[j][y[i]])%mod*inv%mod;
		}
	}
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++) ans=(ans+f[i][j])%mod;
	}
	ans=ans*p%mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 70784
import math

a, b, x = map(int, input().split())

half = a*a*b/2
if half == x:
    print(45)
elif half > x:
    print(math.degrees(math.atan(a*b*b/(x*2))))
else:
    print(math.degrees(math.atan(2*(a*a*b-x)/(a*a*a))))

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N, X;
    int m;
    int min_Gram = INT_MAX;
    
    cin >> N >> X;
    
    for(int i = 0; i < N; i++){
        cin >> m;
        min_Gram = min(min_Gram, m);
        X -= m;
    }
    

    
    cout << N + (X / min_Gram) << endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std ; 
const int N=1e6+3,Mod= 1e9+7;
long long int dp[ N][2][2]; 
int n ; 
long long calc(int idx ,bool zero ,bool nine){
       //cout<<1;
        if (idx==n and nine and zero){
                 return 1 ; 
        }if(idx>=n)return 0 ; 
        long long &ret = dp[idx][zero][nine];
        if(ret!=-1)return ret ; 
        ret =0 ; 
        bool z =0 ,n =0 ; 
        for(int i =0;i<10;i++){
                
               if(i==9)ret += calc(idx+1 ,zero, 1)%Mod;
               else if(i==0) ret +=calc(idx+1,1,nine)%Mod;
               else ret+=calc(idx+1,zero ,nine)%Mod;
                ret %=Mod ; 
        }return ret %= Mod; 
}
int main(){ 
  cin >> n ; 
  memset(dp, -1, sizeof dp);
  
  cout<<calc(0,0,0)%Mod;
        //cout<<2;
}
  

Measured memory_bytes: 128396
#include <bits/stdc++.h>
using ll = long long int;
using namespace std;
ll mod=1e9+7;
      
      
int main(){
  int n,m;
  cin >> n>>m;
  int a[m];
  int q=0;
  for(int i=0;i<m;i++)cin >> a[i];
  ll dp[n+3]; //段数、＝方法の通り
  dp[0]=1;
  if(a[0]!=1){dp[1]=1;}else{dp[1]=0,q++;}
  for(int i=1;i<=n+1;i++){
      if(a[q]==i+1){dp[i+1]=0,q++;
      continue;}
     dp[i+1]=(dp[i]+dp[i-1])%mod;
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 1408
#include <cstdio>
 
char c[15][15],d[15],e[15];
int i,m,n;
 
inline bool dfs2(int x)
{
    if (x>m)
        return true;
    if (e[x])
        return dfs2(x+1);
    else
    {
        int t=0,r=0;
        for (int i=x;i<=m;i++)
            if (! e[i])
                t++;
        for (int i=x;i<=m;i++)
            if (! e[i])
            {
                e[x]=i,e[i]=x,r=1;
                for (int j=1;j<=n;j++)
                    if ((c[j][x]!=c[d[j]][i]) || (c[d[j]][x]!=c[j][i]))
                    {
                        r=0;
                        break;
                    }
                if(i==x){
                    if(r&&(t&1)&&dfs2(x+1))return true;
                }
                else{
                    if(r){
                        if(dfs2(x+1))return true;else return false;
                    }
                }
                /*if ((r) && ((t&1) || (i!=x)) && (dfs2(x+1)))
                    return true;
                else if(i!=x)return false;*/
                e[x]=0,e[i]=0;
            }
    }
    return false;
}
 
inline bool dfs1(int x)
{
    if (x>n)
        return dfs2(1);
    if (d[x])
        return dfs1(x+1);
    else
    {
        int t=0;
        for (int i=x;i<=n;i++)
            if (! d[i])
                t++;
        for (int i=x;i<=n;i++)
            if (! d[i])
            {
                d[x]=i,d[i]=x;
                if (((t&1) || (i!=x)) && (dfs1(x+1)))
                    return true;
                d[x]=0,d[i]=0;
            }
    }
    return false;
}

int main()
{
    scanf("%d%d",&n,&m);
    for (i=1;i<=n;i++)
        scanf("%s",c[i]+1);
    if (dfs1(1))
        puts("YES");
    else
        puts("NO");
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>

using namespace std;

int main(){
    int n;
    while(cin >> n){
        int arr[n];
        int total=0;
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        for(int i=0;i<n;i++){
            for(int j=1;j<n;j++){
                for(int k=2;k<n;k++){
                    if(i<j && j<k && arr[i]!=arr[j] && arr[j]!=arr[k] && arr[i]!=arr[k] && arr[i]+arr[j]>arr[k] && arr[j]+arr[k]>arr[i] && arr[i]+arr[k]>arr[j]){
                        total+=1;
                    }
                }
            }
        }cout << total << '\n';
    }
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
  ll n,a,b;
  cin >> n >> a >> b; //n=数の個数
  if(a>b||(n==1&&a!=b)){
    cout << 0 << endl;
    return 0;
  }
  if((n==1&&a==b)){
    cout << 1 << endl;
    return 0;
  }
  ll ans = (n-2)*(b-a)+1;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int x;
	cin >> x;
	rep(i, 10e9) {
		if (i*(i + 1) / 2 >= x) {
			print(i);
			return 0;
		}
	}
}

Measured memory_bytes: 3648
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr int MOD_TYPE = 1;
constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
constexpr int INF = (int)1e9;
constexpr ll LINF = (ll)4e18;
constexpr ld PI = acos(-1.0);
constexpr ld EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

#pragma endregio

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);

  int n;
  cin >> n;
  int h[101];
  rep(i, n) cin >> h[i];
  h[n] = -1;
  int cnt = 0;
  rep(ti, 100)
  {
    bool b = false;
    rep(i, n)
    {
      if (h[i] > 0)
      {
        b = true;
      }
      if (b && h[i + 1] <= 0)
      {
        b = false;
        cnt++;
      }
    }
    rep(i, n) h[i]--;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
typedef long long ll;

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }
inline ll getLL(){ ll s; scanf("%lld", &s); return s; }
#include <set>
using namespace std;

template<class T>
T gcd(T a, T b){
  if(a > b){ T tmp = b; b = a; a = tmp; }
  if(a == 0) return b;
  return gcd(a, b % a);
}

int main(){
  const int n = getInt();
  const ll  m = getLL();
  vector<ll> a(n);  REP(i,n) a[i] = getLL();
  vector<int> p(n); REP(i,n) p[i] = getInt();

  double ans = 0.0;

  REP(i,1 << n) if(i){
    double prob = 1.0;
    ll mul = 1;

    REP(j,n) if(i & (1 << j)){
      prob *= p[j] / 100.0;

      if(mul > 0){
        ll next = mul / gcd(mul, a[j]);
        if(next > m / a[j]) mul = -1;
        else mul = next * a[j];
      }
    }

    if(mul > 0){
      if(__builtin_popcount(i) % 2)
        ans += prob * (m / mul);
      else
        ans -= prob * (m / mul);
    }
  }

  printf("%.9f\n", ans);

  return 0;
}

Measured memory_bytes: 1080
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pll pair<ll,ll>
int main() {
  ll N; 
  cin >> N;
  ll balls[N]; 
  for(int i=0;i<N;i++){
    cin >> balls[i]; 
  }
  ll total = 0; 
  ll no[N + 10];
  memset(no,0,sizeof(no)); 
  for (int i=0; i < N; i++){
      ll v = no[balls[i]]; 
      total -= (v * (v - 1))/2; 
      no[balls[i]]++; 
      v = no[balls[i]]; 
      total += (v * (v - 1))/2; 
  }
  ll total1 = total; 
  for (int j = 0; j < N; j++){
    total = total1; 
    ll v = no[balls[j]]; 
    total -= (v * (v - 1))/2;
    v--;
    total += (v * (v - 1))/2;
    
    cout << total << endl; 
  }
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n; cin >> n;
  int res = 0;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; ++j) {
      if (i % j == 0) {
        ++cnt;
      }
    }
    if (cnt == 8) {
      ++res;
    }
  }
  cout << res << endl;

}


Measured memory_bytes: 256
import java.util.*;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Collections;


public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String t = br.readLine();
        
        boolean matched;
        //String ans = "UNRESTORABLE";;
        List<String> cand = new ArrayList();
        for (int i = s.length()-t.length(); i >= 0; i--) {
            //System.out.println(i);
            matched = true;
            for (int j = 0; j < t.length(); j++) {
                if (s.charAt(i+j) == t.charAt(j) || s.charAt(i+j) == '?') continue;
                else {
                    matched = false;
                    //ans = "UNRESTORABLE";
                    break;
                }
            }
            if (matched) {
                //ans = s.substring(0, i) + t;
                StringBuilder ans = new StringBuilder(s);
                ans.replace(i, i+t.length(), t);
                //System.out.println(i);
                cand.add(ans.toString().replace("?", "a"));
                //break;
            }
        }
        Collections.sort(cand);
        if (cand.isEmpty()) {
            System.out.println("UNRESTORABLE");
        }
        else System.out.println(cand.get(0));
    }
}

class Box {
    int w;
    int h;
    public Box(int w, int h) {
        this.w = w;
        this.h = h;
    }
}

class BoxComparator1 implements Comparator<Box>{
	public int compare(Box b1, Box b2) {
		return b1.w - b2.w;
	}
}

class BoxComparator2 implements Comparator<Box> {
    public int compare(Box b1, Box b2) {
        return b1.h - b2.h;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

string S;
ll L;
vector<string> ss;

ll stringtoi(string s){
    ll res = 0;
    rep(i,s.size()){
        res *= 10;
        res += (s[i] - '0');
    }
    return res;
}

string itos(ll num){
    string res = "";
    rep(i,L){
        res += (char)(num % 10 + '0');
        num /= 10;
    }
    reverse(ALL(res));
    return res;
}

string calc(string a){
    sort(ALL(a));
    ll tmp1 = stringtoi(a);
    reverse(ALL(a));
    ll tmp2 = stringtoi(a);
    return itos(tmp2 - tmp1);
}

int main(){
    while(cin >> S >> L){
        if(S == "0" && L == 0)break;
        ss.clear();
        while(S.size() < L){
            S = "0" + S;
        }
        ss.push_back(S);
        while(1){
            string t = calc(S);
            // cout << "!" << t << endl;
            auto it = find(ALL(ss),t);
            if(it != ss.end()){
                ll j = it - ss.begin();
                cout << j << " " << stringtoi(t) << " " << ss.size() - j << endl;
                break;
            }
            ss.push_back(t);
            S = t;
        }
    }
}


Measured memory_bytes: 3216
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<vector>

using namespace std;
typedef long long int Int;

//f(n) =0以上n以下の整数のうち条件を満たすものの個数
Int f(Int n, Int x){
  if(n == -1){
    return 0;
  }
  return n/x + 1 ;
}
int main(){

  Int a,b,i,x;
  cin >> a >> b >> x;
  cout << f(b,x) - f(a-1,x) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a[100], n, i;
	scanf("%d", &n);
	
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	for (i = i - 1; i >= 0; i--)
	{
		printf("%d", a[i]);
		if (i != 0)
			putchar(' ');
		else
			putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String str = "";

        while(sc.hasNext()){
            String a = sc.nextLine();
            str = str + a;
        }

        int l = str.length();
        int[] num = new int[26];

        for(int i=0;i<l;i++){
            int c = (int)str.charAt(i);
            if('a'<=c && c<='z'){
                num[c-'a']++;
            }else if('A'<=c && c<='Z'){
                num[c-'A']++;
            }
        }

        for(int i=0;i<26;i++){
            System.out.printf("%c : %d\n", i+'a', num[i]);
        }
    }
}




Measured memory_bytes: 26372
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int a = 0 ,b = 0 ;
	string s1,s2;
	cin >> s1 >> s2 ;
	for(int cnt = 0 ,a=0,b=0; a<s1.size() || b<s2.size(); cnt++ )
    {
        if(cnt%2==0)
        {
            cout << s1[a++] ;
        }
        else
            cout << s2[b++] ;
    }
    cout << endl;

}


Measured memory_bytes: 3592
a_num, b_num, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [input().split() for i in range(m)]

ans = min(a) + min(b)
for i in range(m):
  p = int(xyc[i][0])
  q = int(xyc[i][1])
  r = int(xyc[i][2])
  if a[p-1] + b[q-1] - r < ans:
    ans = a[p-1] + b[q-1] - r

print(ans)

Measured memory_bytes: 45736
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        if (n <= 104) { Console.WriteLine(0); goto end; }
        if (n <= 106) { Console.WriteLine(1); goto end; }
        var res = 1;
        for (int i = 107; i <= n; i += 2)
        {
            var count = 1;
            for (int j = 1; j <= n/2; j+= 2)
                if (i % j == 0) count++;
            if (count == 8) res++;
        }
        Console.WriteLine(res);
        end:;
    }
}

Measured memory_bytes: 11092
import java.io.*;
 
class Main {
    public static void main(String[] args)throws IOException{ 
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader read = new BufferedReader(in);
        
        	int num,count,spinA,spinB,spinC;
        	
        	String number1 = read.readLine();
	        String[] spli1 = number1.split(" ");
	        int [] dice1 = new int [9];
	        for(count = 0; count < 9; count++){ 
	        	dice1[count] = 0;
	        }
	        for(num = 0; num < 6; num++){
	        	dice1[num] = Integer.parseInt(spli1[num]);
	        }
	        	
	        String number2 = read.readLine();
	        String[] spli2 = number2.split(" ");
	        int [] dice2 = new int [6];
	        for(count = 0; count < 6; count++){ 
	          	dice2[count] = 0;
	        }
	        for(num = 0; num < 6; num++){
	        	dice2[num] = Integer.parseInt(spli2[num]);
	        }
	        
	        
	        	for(spinA = 0; spinA < 4; spinA++){
	        		if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] && dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
	        			System.out.println("Yes");
	        			break;
        			}
        			else{
        				dice1[6] = dice1[0];
        				dice1[0] = dice1[1];
        				dice1[1] = dice1[5];
        				dice1[5] = dice1[4];
        				dice1[4] = dice1[6];
        				
		        		for(spinB = 0; spinB < 4; spinB++){
		        			if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] && dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
		        				break;
		        			}
		        			else{
		        				dice1[6] = dice1[1];
		        				dice1[7] = dice1[2];
		        				dice1[8] = dice1[4];
		        				dice1[1] = dice1[3];
		        				dice1[2] = dice1[6];
		        				dice1[4] = dice1[7];
		        				dice1[3] = dice1[8];
		        				
			        			for(spinC = 0; spinC < 4; spinC++){
				        			if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] && dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
				        				break;
				        			}
				        			else{
				        				dice1[6] = dice1[2];
				        				dice1[7] = dice1[0];
				        				dice1[8] = dice1[3];
				        				dice1[2] = dice1[5];
				        				dice1[0] = dice1[6];
				        				dice1[3] = dice1[7];
				        				dice1[5] = dice1[8];
				        			}
			        			}
			        		}
		        		}
        			}
	        	}
	        	if(dice1[0] == dice2[0] && dice1[1] == dice2[1] && dice1[2] == dice2[2] && dice1[3] == dice2[3] && dice1[4] == dice2[4] && dice1[5] == dice2[5]){
	        	}
	        	else{
	        		System.out.println("No");
	        	}
    }
}

Measured memory_bytes: 24336
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int64 power_mod(int64 a, int64 n, int p = MOD) {
  int64 ret = 1;
  for (; n; n >>= 1) {
    if (n & 1) ret = ret * a % p;
    a = a * a % p;
  }
  return ret;
}

int64 inv_mod(int64 a) {
  return power_mod(a, MOD - 2);
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int64 ret = (power_mod(2, n) + MOD - 1) % MOD;
  int64 A = 1, B = 1;
  for (int i = 0; i < a; ++i) A = A * (n - i) % MOD * inv_mod(i + 1) % MOD;
  for (int i = 0; i < b; ++i) B = B * (n - i) % MOD * inv_mod(i + 1) % MOD;
  // trace(ret, A, B);
  ret = (ret + MOD - A) % MOD;
  ret = (ret + MOD - B) % MOD;
  cout << ret << endl;
  return 0;
}


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

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

Measured memory_bytes: 3108
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int N;
    string S;
    cin >> N >> S;
    if(N%2==1){
        COUT("No");
        return 0;
    }
    rep(i,0,N/2){
        if(S[i]==S[N/2+i]) continue;
        else{
            COUT("No");
            return 0;
        }
    }
    COUT("Yes");
}




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

int main(void)
{
    int n;
    scanf("%d", &n);

    for (int i = 0; i <= 20; i++) {
        for (int j = 0; j <= 14; j++) {
            if (n == 4 * i + 7 * j) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		//??????????????°
		Scanner sc;		//??\???
		int a=0;
		int b=0;
		int kotae=0;
		int i=0;

		sc = new Scanner(System.in);

		while(sc.hasNext()){

			a = sc.nextInt();
			b = sc.nextInt();
			kotae = a + b;

			String skotae = String.valueOf(kotae);
			int keta = skotae.length();

			System.out.println(keta);
			i= i+1;
		}
	}
}

Measured memory_bytes: 26408
#include <stdio.h>
int main(void){
    int N,K;
    scanf("%d %d",&N,&K);
    int unko=1;
    for(int i=0;i<N;i++){
        if(unko<K)unko*=2;
        else unko+=K;
    }
    printf("%d",unko);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,k,s,f[100010];
map<int,int> m;
void solve()
{
    cin>>n>>k>>s;
    int cur=s;
    m[0]=1;
    while(k--)
    {
        m[cur]=1;
        cur+=s;
        n--;
    }
    cur=1;
    while(n--)
    {
        while(m.find(cur)!=m.end()||
           m.find(cur-s)!=m.end()||
           m.find(cur+s)!=m.end()
           )cur++;
        m[cur]=1;
        cur++;
    }
    int pre=0;
    for(auto it:m)
      {
          if(it.fi==0)continue;
          cout<<it.fi-pre;
          pre=it.fi;
          cout<<" ";
      }
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int test;cin>>test;while(test--)
    solve();
    return 0;
}


Measured memory_bytes: 7552
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int N;  cin>>N;
    vector<int>a(N);
    rep(i,N)a[i]=i+1;
    vector<int>b(N);
    vector<int>c(N);
    rep(i,N){
        int p; cin>>p;
        b[i]=p;
    }
    rep(i,N){
        int q; cin>>q;
        c[i]=q;
    }
    int bb,cc;
    int cnt=0;
    do{
        cnt++;
        if(a==b)bb=cnt;
        if(a==c)cc=cnt;
    }while(next_permutation(a.begin(),a.end()));
    cout<<abs(bb-cc)<<endl;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.node_size = [1] * n
        self.edge_size = [0] * n
        self.rank = [0] * n

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

    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def get_node_size(self, x):
        return self.node_size[self.find(x)]

    def get_edge_size(self, x):
        return self.edge_size[self.find(x)]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            self.edge_size[x] += 1
        else:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
                self.edge_size[y] += self.edge_size[x] + 1
                self.node_size[y] += self.node_size[x]
            else:
                self.par[y] = x
                self.edge_size[x] += self.edge_size[y] + 1
                self.node_size[x] += self.node_size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

n, m = [int(item) for item in input().split()]
UF = UnionFind(n)
for i in range(m):
    x, y = [int(item) - 1 for item in input().split()]
    UF.union(x, y)

unconnected_node = 0
unconnected_edge = 0
seen = set()
p0 = UF.find(0)
p1 = UF.find(1)
for i in range(n):
    pi = UF.find(i)
    if pi != p0 and pi != p1:
        if pi not in seen:
            unconnected_edge += UF.edge_size[pi]
            unconnected_node += UF.node_size[pi]
            seen.add(pi)

if UF.get_node_size(0) > UF.get_node_size(1):
    large = 0
    small = 1
else:
    large = 1
    small = 0

A = UF.get_node_size(large) + unconnected_node
B = UF.get_node_size(small)
ans = A * (A - 1) // 2 + B * (B - 1) // 2
ans -= UF.get_edge_size(large) + UF.get_edge_size(small) + unconnected_edge
print(ans)

Measured memory_bytes: 18360
#include<stdio.h>

#define N 101

void DFS(int);

int Adj[N][N],Dfs[N],d[N],f[N];
int n,count=1;

int main( ){
  int i,j,k,l,v,u;

  scanf("%d",&n);

  Dfs[0] = 0;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      Adj[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      Adj[u][v] = 1;
    }
  }

  for(i=0;i<n;i++){
    if(Dfs[i]==0){
      DFS(i);
    }
  }
    for(i=0;i<n;i++){
      printf("%d %d %d\n",i+1,d[i],f[i]);
    }
    return 0;
  }

  
void DFS(int x) {
  int y;

  d[x] = count++;
  Dfs[x] = 1;
  for(y = 0 ; y < n ; y++) {
    if(Adj[x][y] == 1 && Dfs[y] == 0) {
      DFS(y);
    }
  }
  f[x] = count++;
}
  



Measured memory_bytes: 2088
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

const double PI = acos(-1.0);

int main() {
    double r;
    cin >> r;
    printf("%.10lf\n", r * 2 * PI);
}

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

void fast_IO() { ios_base::sync_with_stdio(false);cin.tie(NULL);}
void test_here_once(){ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);}


string lcs2(string s, string t, int n, int m)
{
	int dp[n+1][m+1];

	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			if(i==0||j==0) dp[i][j]=0;

	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s[i-1]==t[j-1]) dp[i][j]= 1+ dp[i-1][j-1];
			else
			{
				dp[i][j]= max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}

	string ans="";

	int i=n,j=m;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1]) ans+=s[i-1], i--,j--;
		else
		{
			if(dp[i-1][j]>=dp[i][j-1]) i--;
			else j--;
		}
	}
	return ans;	
}

void fun()
{
	string s,t; cin>>s>>t;
	int n=s.length(), m=t.length();
	string ans= lcs2(s,t,n,m);
	reverse(ans.begin(), ans.end());
	cout<<ans;
}

int main()
{
	//test_here_once();
	fast_IO();

	fun();
/*	int t; cin>>t;
	while(t--)
	{
		fun();
	}*/
}

Measured memory_bytes: 38804
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()

def main():
    N=ii()
    A = list(mi())

    counter = [0]*(10**5+5)

    for a in A:
        counter[a] += 1

    ans = sum(A)

    Q=ii()
    for q in range(Q):
        B,C=mi()
        ans -= B * counter[B]
        ans += C * counter[B]

        counter[C] += counter[B]
        counter[B] = 0
        print(ans)




if __name__ == "__main__":
  main()

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

using namespace std;

int main() {
  string s, result = "";
  cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'B') {
			if (result.size()) {
					result.pop_back();
			}
		}
		else {
			result.push_back(s[i]);
		}
	}
	cout << result;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{
    lint n, m;
    scanf("%lld", &n);
    scanf("%lld", &m);

    std::vector<std::vector<lint>> bulb(m);
    std::vector<lint> remainder(m);

    for (int i = 0; i < m; ++i)
    {
        lint k;
        scanf("%lld", &k);

        for (int j = 0; j < k; ++j)
        {
            lint s;
            scanf("%lld", &s);
            bulb[i].push_back(s);
        }
    }

    for (int i = 0; i < m; ++i)
    {
        lint q;
        scanf("%lld", &q);
        remainder[i] = q;
    }

    lint ans = 0;

    std::vector<lint> sw(n);

    for (lint i = 0; i < (1 << n); i++)
    {
        for (lint j = 0; j < n; j++)
        {
            if (i >> j & 1 == 1)
            {
                sw[j] = 1;
            }
            else
            {
                sw[j] = 0;
            }
        }

        lint all = 1;

        for (int k = 0; k < m; ++k)
        {
            lint sum = 0;
            for (auto con = bulb[k].begin(); con != bulb[k].end(); con++)
            {
                sum += sw[*con - 1];
            }
            if (sum % 2 != remainder[k])
            {
                all--;
            }
        }

        if (all > 0)
        {
            ans++;
        }
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
max = 10 ** 20 * -1
if a*c >= max:
  max = a*c
if a*d >= max:
  max = a*d
if b*c >= max:
  max = b*c
if b*d >= max:
  max = b*d
  
print(max)


Measured memory_bytes: 9076
#%%
import copy 

H, W = map(int, input().split())
c = [[int(_) for _ in input().split()] for _ in range(10)]
A = [[int(_) for _ in input().split()] for _ in range(H)]

d = copy.deepcopy(c)

for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])


ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] == 0 or A[i][j] >= 2:
            ans += d[A[i][j]][1]


print(ans)

Measured memory_bytes: 3820
X = int(input())
ans = 0
if 400 <= X <= 599:
    ans = 8
elif 600 <= X <= 799:
    ans = 7
elif 800 <= X <= 999:
    ans = 6
elif 1000 <= X <= 1199:
    ans = 5
elif 1200 <= X <= 1399:
    ans = 4
elif 1400 <= X <= 1599:
    ans = 3
elif 1600 <= X <= 1799:
    ans = 2
elif 1800 <= X <= 1999:
    ans = 1
print(ans)


Measured memory_bytes: 9180
#include <cstdio>
#include <algorithm>
#include <queue>
#define maxn 805
#define INF 23333333
#define hh(x) (((x)>0)?((x)-1)/K+1:0)
using namespace std;
 
int ans=INF,sum,H,W,K,x1,y1,f[maxn][maxn][4];
int vis[maxn][maxn],fx[4][2]={{-1,0},{0,-1},{1,0},{0,1}};
int tmp,xxx,yyy,x,y,dep;
char map[maxn][maxn];
 
struct xx
{
	int x,y,dep;
};
queue <xx > q;
inline int check(int x,int y)
{
	return 1<=x&&x<=H&&
	       1<=y&&y<=W&&
		   map[x][y]!='#';
}
 
inline void bfs()
{
	q.push((xx){x1,y1,0});
	while (!q.empty())
	{
		xx now=q.front();q.pop();
		x=now.x,y=now.y,dep=now.dep;
		if (dep>K) continue;
		vis[x][y]=1;
		tmp=min(min(H-x,W-y),min(x-1,y-1));
		tmp=(tmp+K-1)/K;
		if (tmp+1>ans) continue;
		ans=min(ans,tmp+1);
	//printf("-- x:%d y:%d dep:%d tmp+1:%d\n--",x,y,dep,tmp+1);
		for (int i=0;i<4;++i)
		{
			xxx=x+fx[i][0];
			yyy=y+fx[i][1];
			if (check(xxx,yyy)&&!vis[xxx][yyy])
				  q.push((xx){xxx,yyy,dep+1}),vis[xxx][yyy]=1;
		}
	}
	return ;
}
 
int main()
{
	scanf("%d%d%d",&H,&W,&K);
	for (int i=1;i<=H;++i) scanf("%s",map[i]+1);
	for (int i=1;i<=H;++i)
	  for (int j=1;j<=W;++j)
	  	  if ('S'==map[i][j]) x1=i,y1=j;
	if (x1==1||x1==H||y1==1||y1==W) ans=0;
	else bfs();
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 3328
/* nothing is impossible */
#include <bits/stdc++.h> 
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef double ld;
typedef string st;
const double PI=3.14159265358979323846264338327950288419716939937510582097494459230;
const ll MOD = 1e9 + 7 ;
const ll INF=1e14;                                                                                                 
ll mpow(ll a,ll b,ll p=MOD){a=a%p;ll res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}             

int main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //freopen("input.txt", "r", stdin);
  ll n;
  cin>>n;
  if(n<1200) cout<<"ABC";
  else if(n<2800) cout<<"ARC";
  else cout<<"AGC"; 
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	int a[n],b[n],c[n];
	for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	int dpa[n]={0};int dpb[n]={0};int dpc[n]={0};
	dpa[0]=a[0];dpb[0]=b[0]; dpc[0]=c[0];
	for(int i=1;i<n;i++){
		dpa[i]=max(dpb[i-1],dpc[i-1])+a[i];
		dpb[i]=max(dpa[i-1],dpc[i-1])+b[i];
		dpc[i]=max(dpb[i-1],dpa[i-1])+c[i];
	}
	cout<<max({dpa[n-1],dpb[n-1],dpc[n-1]})<<endl;
}

Measured memory_bytes: 2560
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Console.ReadLine();
		WriteLine(S.Substring(0, S.Length - "festival".Length));
	}
}


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

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

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

    vi a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(all(a));
    if(a[0]==5 && a[1]==5 && a[2] == 7)
        cout << "YES";
    else
        cout << "NO";
}

Measured memory_bytes: 256
(defun App ()
(let ((a (read))
    (b (read))
    (c (read))
    (k (read))
    (ans 0))
    (if (< k (+ a b))
        (format t "~D~%" k)
        (format t "~D~%" (- a (- k a b)))
    )
   )
)

(App)

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

int main(){
    long long a, b, x, tmpp;
    long long c, d, tmp, r, tmpc, tmpd;
    cin >> a >> b >> c >> d;
    x = c * d;
    tmpp =  b - a + 1;
    tmpc = c;
    tmpd = d;
    /* 自然数 a > b を確認・入替 */
    if(c < d){
        tmp = c;
        c = d;
        d = tmp;
    }
 
    /* ユークリッドの互除法 */
    r = c % d;
    while(r!=0){
        c = d;
        d = r;
        r = c % d;
    }
    // cout << b - a  + 1 << endl;
    // cout << tmpp << endl;
    // cout << x << endl;
    // cout << d << endl;
    cout <<  tmpp - b / tmpc  + (a - 1) / tmpc - b / tmpd + (a - 1) / tmpd + b / (x / d) - (a - 1) / (x / d) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
bool fx[30][30],fy[30][30];
int d[30][30];
int dx[4]={0,-1,-0,1},dy[4]={1,0,-1,0};
int H,W;
int main(){
	while(cin>>W>>H&&W&&H){
		bool ok=false;
		rep(i,30)rep(j,30){
			d[i][j]=-1;
			fx[i][j]=false;
			fy[i][j]=false;
		}
		rep(i,H){
			rep(j,W-1)cin>>fx[j][i];
			if(i==H-1)break;
			rep(j,W)cin>>fy[j][i];
		}
		queue<pair<int,int> >q;
		q.push(MP(0,0));
		d[0][0]=1;
		while(!q.empty()){
			int x=q.front().first,y=q.front().second;q.pop();
			if(x==W-1&&y==H-1)ok=true;
			if(!fx[x][y]&&x+1<W&&d[x+1][y]==-1){
				q.push(MP(x+1,y));d[x+1][y]=d[x][y]+1;
			}
			if(!fy[x][y]&&y+1<H&&d[x][y+1]==-1){
				q.push(MP(x,y+1));d[x][y+1]=d[x][y]+1;
			}
			if(!fx[x-1][y]&&x-1>=0&&d[x-1][y]==-1){
				q.push(MP(x-1,y));d[x-1][y]=d[x][y]+1;
			}
			if(!fy[x][y-1]&&y-1>=0&&d[x][y-1]==-1){
				q.push(MP(x,y-1));d[x][y-1]=d[x][y]+1;
			}
		}
		if(ok)cout<<d[W-1][H-1]<<endl;
		else cout<<0<<endl;
	}
}

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

int main()
{
    string s; cin>>s;
    int n=s.size();
    int res=1<<30;
    for(int i=0; i+2<n; ++i) {
        int a=stoi(s.substr(i, 3));
        res=min(res, abs(a-753));
    }
    cout<<res<<endl;
}


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

int main() {
  int k;
  cin >> k;
  if (k%2==0 || k%5==0) {
    cout << -1;
    return 0;
  }
  int ans = 1;
  int r = 7;
  while (ans <= k) {
    if (r%k == 0) {
      cout << ans;
      break;
    }
    r = (r * 10 + 7) % k;
    ans++;
  }
  return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>

using namespace std;


int main()
{
    int temp;
    int min_value=2e9;
    //cout<<max_value<<endl;
    int max_income=-2e9;
    //cout<<min_value<<endl;
    int n;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%d",&temp);
        max_income=max(max_income,temp-min_value);
        min_value=min(min_value,temp);
        //cout<<"$"<<max_income<<"^^^"<<min_value<<endl;
    }
    printf("%d\n",max_income);
    return 0;
}



Measured memory_bytes: 3204
$p = []

def main
  n = gets.to_i
  $m = Array.new(n) { Array.new(n).map{ 0 }}
  n.times do |i|
    $p[i], $p[i + 1] = gets.split.map(&:to_i)
  end
  2.upto(n) do |l|
    1.upto(n - l + 1) do |i|
      j = i + l - 1
      $m[i - 1][j - 1] = 1.0 / 0.0
      i.upto(j - 1) do |k|
        $m[i - 1][j - 1] = [$m[i - 1][j - 1], $m[i - 1][k - 1] + $m[k][j - 1] + $p[i - 2] * $p[k - 1] * $p[j - 1]].min
      end
    end
  end
  p $m[0][n - 1]
end

main



Measured memory_bytes: 7024