akhauriyash/Code-Regression huggingface dataset:
H, W = map(int, input().split(' '))

S = [input() for _ in range(H)]

rows = []
cols = []

for y in range(H):
    cont = 0
    row = []
    for x in range(W):
        if S[y][x] == '.':
            cont += 1
        else:
            for _ in range(cont):
                row.append(cont)
            row.append(0)
            cont = 0
    for _ in range(cont):
        row.append(cont)
    rows.append(row)

for x in range(W):
    cont = 0
    col = []
    for y in range(H):
        if S[y][x] == '.':
            cont += 1
        else:
            for _ in range(cont):
                col.append(cont)
            col.append(0)
            cont = 0
    for _ in range(cont):
        col.append(cont)
    cols.append(col)

ans = 0
for y in range(H):
    for x in range(W):
        if S[y][x] == '.':
            ans = max(ans, rows[y][x] + cols[x][y] - 1)

print(ans)


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


int main() {
    ll n,a,b;
    cin >> n >> a >>b;
    ll ans = 0;
    ll d = n/(a+b);
    if(n%(a+b) == 0){
        cout << a*d << endl;
    }else{
        if(n%(a+b) > a)cout << a*d + a << endl;
        else cout << a*d + n%(a+b) << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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

#define int long long
#define all(v) (v).begin(), (v).end()
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

const int INF = 1e18;

int N, A, B, C;
vector<int> l;

// Aに使う竹の集合、Bに使う竹の集合、Cに使う竹の集合を渡すと、作りたい竹にするのにかかるコストを返してくれる
int calc(vector<int> &a, vector<int> &b, vector<int> &c) {
  int aRes = abs(accumulate(all(a), 0LL) - A) + ((a.size()-1) * 10);
  int bRes = abs(accumulate(all(b), 0LL) - B) + ((b.size()-1) * 10);
  int cRes = abs(accumulate(all(c), 0LL) - C) + ((c.size()-1) * 10);

  return aRes + bRes + cRes;
}

int rec(int idx, vector<int> &a, vector<int> &b, vector<int> &c) {
  if (idx >=  N) {
    if (a.size() == 0 or b.size() == 0 or c.size() == 0) return INF;
    return calc(a, b, c);
  }

  int ret = INF;

  // idx番目の竹をAに使う
  a.push_back(l[idx]);
  chmin(ret, rec(idx+1, a, b, c));
  a.pop_back();

  // idx番目の竹をBに使う
  b.push_back(l[idx]);
  chmin(ret, rec(idx+1, a, b, c));
  b.pop_back();

  // idx番目の竹をCに使う
  c.push_back(l[idx]);
  chmin(ret, rec(idx+1, a, b, c));
  c.pop_back();

  // idx番目の竹を使わない
  chmin(ret, rec(idx+1, a, b, c));

  return ret;
}

signed main() {
  cin >> N >> A >> B >> C;
  l.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }

  vector<int> a;
  vector<int> b;
  vector<int> c;
  cout << rec(0, a, b, c) << endl;

  return 0;
}

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

int main() {
  int64_t K, money, cnt;
  cin >> K;
  money = 100;
  cnt = 0;
  
  while(money<K){
    money = money*1.01;
    cnt++;
  }
  
  cout << cnt;
    
}
 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int sum=0,m=0,b=n;
	while(n>0){
		m=n%10;
		n/=10;
		sum+=m;
	}
	//cout<<sum<<endl;
	//cout<<b%sum<<endl;
	//if(sum==0) printf("No\n");//
	if(b%sum==0) printf("Yes\n");
	else if(b%sum!=0) printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include "stdio.h"

int main() {
  int n, h[100], max, i, flag=1;

  scanf("%d", &n);

  for ( i = 0; i < n; i++) {
    scanf("%d", &h[i]);
    if(i == 0) {
      max = h[i];
    }
    else {
      if(max <= h[i]) {
        max = h[i];
        flag++;
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 1000005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<lln> vi;
vector<lln>vi2;
vector<lln>vi3;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


//int arr[maxii];
//lln arr2[maxii];
//bool check[maxii];
//bool check2[1000][1000];

int arr[maxii];
bool prim[maxii];
int p=0;
void prime()
{
    for(lln i=3;i*i<=maxii;i+=2)
    {
        if(prim[i]==false)
        {
            for(lln j=i*i;j<=maxii;j+=i+i)
            {
                prim[j]=true;
            }
        }
    }
    arr[p++]=2;
    for(int i=3;i<=maxii;i+=2)
    {
        if(prim[i]==false)
        {
            arr[p++]=i;
        }
    }
}
int pp;
void fact(lln n)
{
    for(int i=0;i<p && arr[i]*arr[i]<=n;i++)
    {
        if(n%arr[i]==0)
        {
            vi3.pb(arr[i]);
            while(n%arr[i]==0)
            {
                n/=arr[i];
            }
        }
    }
    if(n>1)
    {
        vi3.pb(n);
    }
}
int g=0;
lln cal(lln nn)
{
    //nn;
    //cout<<"first:"<<endl;
    for(int i=0;i<vi3.size() && vi3[i]<=nn;i++)
    {
        //cout<<nn<<" "<<endl;
        if(nn%vi3[i]==0)
        {
            //lln d=arr2[i]-1;
            nn/=vi3[i];
            nn*=(vi3[i]-1);
        }
    }
    return nn;
}
int main()
{
  int n,k;
  cin>>n>>k;
  int sum=k;
  k--;
  n--;
  for(int i=0;i<n;i++)
  {
      sum*=k;
  }
  cout<<sum;
}






Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int r[10];
int dist[202][202];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, R;
  cin >> N >> M >> R;
  fill(dist[0], dist[N], INF);
  REP(i,R){
    cin >> r[i];
    r[i]--;
  }
  REP(i,M){
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = dist[b][a] = c;
  }

  REP(k,N)
    REP(i,N)
    REP(j,N)
    dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

  int dp[1 << 8][8];
  fill(dp[0], dp[(1 << 8)], INF);
  REP(i,R){
    dp[1 << i][i] = 0;
  }
  for(int i = 0; i < 1 << R; i++){
    REP(u, R){
      if((i & (1 << u)) == 0) continue;
      REP(v, R){
        if(i & (1 << v)) continue;
        dp[i | (1 << v)][v] = min(dp[i | ( 1 << v)][v], dp[i][u] + dist[r[u]][r[v]]);
      }
    }
  }
  cout << *min_element(dp[(1 << R) - 1], dp[1 << R]) << endl;
  return 0;
}


Measured memory_bytes: 384
/**
 * 解説にあった、DP(というかメモ化)を試してみる
 */

#include <iostream>
#include <stack>
#include <unordered_map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>
#include <iterator>
#include <tuple>

using namespace std;

const long long int MOD = 1000000007;
long long int l,r;

int memo[60][2][2][2];

int get_bit(long long int x, int bit) {
  return (x >> bit) & 1;
}

/**
 * 上位ビットからチェックしていく
 * x,yの状態で判定するが、
 * 必要な状態は引数にある4種類のみ
 * これで、選択できる次のビットの組が決まる
 */
int calc(
    bool equal_l, // xのこれまでのビットがLと同じ
    bool equal_r, // yのこれまでのビットがRと同じ
    bool already_msb, // すでに1が立っているビットを比較済み
    int current_bit) // 現在のビット、上位が大きい
{
  if (current_bit < 0) {
    return 1;
  }

  if (memo[current_bit][equal_l][equal_r][already_msb] != -1) {
    return memo[current_bit][equal_l][equal_r][already_msb];
  }

  int r_bit = get_bit(r, current_bit);
  int l_bit = get_bit(l, current_bit);

  bool can_set_1 = !(equal_r && r_bit == 0); // 1を選べないのは、rと同じ状態、かついまのrが0である場合 -> yがrを超える場合
  bool can_set_0 = !(equal_l && l_bit == 1); // 同様に、xがlを下回る場合を除く

  int result = 0;

  // 1, 1
  if (can_set_1) {
    result += calc(equal_l && l_bit == 1,
        equal_r && r_bit == 1,
        true, //1なので無条件に
        current_bit-1);
    result %= MOD;
  }

  // 0, 0
  if (can_set_0) {
    result += calc(equal_l && l_bit == 0,
        equal_r && r_bit == 0,
        already_msb,
        current_bit-1);
    result %= MOD;
  }

  // 0, 1
  if (
      already_msb && // すでに1を比較していて
      can_set_1 && // yに1を立てられて
      can_set_0 // xに0を立てられる
      ) {
    result += calc(equal_l && l_bit == 0,
        equal_r && r_bit == 1,
        already_msb,
        current_bit-1);
    result %= MOD;
  }

  memo[current_bit][equal_l][equal_r][already_msb] = result;

  return result;
}

int main() {
  cin >> l >> r;

  fill((int*)memo, (int*)memo+60*2*2*2, -1); // 配列はfillで初期化できる
  auto result = calc(true, true, false, 59); // 59は2**60 -> Rの最大値を表現可能なビット数

  cout << result << endl;
}


Measured memory_bytes: 256
import itertools
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

l = [i+1 for i in range(N)]
for i, tpl in enumerate(itertools.permutations(l, N)):
    if tpl == P:
        a = i
    if tpl == Q:
        b = i
print(abs(a-b))

Measured memory_bytes: 9096
s = input()
t = input()
while s != "":
  x = s[0]
  y = t[0]
  for i in range(len(s)):
    if (s[i] == x and t[i] != y) or (s[i] != x and t[i] == y):
      print("No")
      exit()
  s = s.replace(x,"")
  t = t.replace(y,"")
print("Yes")

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

void dfs(int v, int p, vector<int> &color, vector<vector<pair<int,int>>> &G){
    for(auto nv : G[v]) if(nv.first != p){
        color[nv.first] = (color[v] + nv.second) % 2;
        dfs(nv.first,v,color,G);
    }
}

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

    vector<vector<pair<int,int>>> G(n);
    rep(i,n-1){
        int a, b, c; cin >> a >> b >> c; a--; b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }

    vector<int> color(n,-1);
    color[0] = 0;
    dfs(0,-1,color,G);

    rep(i,n)  cout << color[i] << endl;
    return 0;
}

Measured memory_bytes: 12480
#include<cstdio>
#include<cstring>
using namespace std;
char s[105],c[105];
int main()
{
	int n = 0;
	scanf("%s",s);
	int len = strlen(s);
	for(int i = 0; i <= len ; i++)
	{
		if(s[i] == 'B')
		{
			n--;
			if(n < 0) n = 0;
		}
		else c[n++] = s[i];
	}
	c[n] = '\0';
	printf("%s",c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
char a[100];
char b[100];
int panduan()
{
    int lena=strlen(a);
    int lenb=strlen(b);
    for(int i=lena-1;i>=0;i--)
    {
        if(a[i]==b[lenb-1]||a[i]=='?')
        {
            int j,k;
            for(j=lenb-1,k=i;j>=0&&k>=0;j--,k--)
            {
                if(a[k]!='?'&&a[k]!=b[j])
                    break;
            }
            //cout<<i<<"_"<<j<<endl;
            if(j==-1)
            {
               for(j=lenb-1,k=i;j>=0&&k>=0;j--,k--)
                a[k]=b[j];
               return 1;
            }
        }
    }
    return 0;
}
int main()
{

    cin>>a;
    cin>>b;
    if(panduan()==1)
    {
        int len=strlen(a);
        for(int i=0;i<len;i++)
        {
            if(a[i]=='?')
                cout<<"a";
            else
                cout<<a[i];
        }
        cout<<endl;
    }
    else
        cout<<"UNRESTORABLE"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define f(n) for(int i=0;i<n;i++)
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 1000000007
#define endl "\n"
//#define int long long
#define ll long long
#define vi vector <int>
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define maxe *max_element
#define mine *min_element
#define pow2(n) (1LL << (n))
#define sz(a) (int)a.size()
#define MOD 1000000007
#define PI 3.14159265359
inline ll add(ll a, ll b){ return ((a%MOD)+(b%MOD))%MOD;}
inline ll mul(ll a, ll b){ return ((a%MOD)*(b%MOD))%MOD;}
inline ll sub(ll a, ll b){ return ((a%MOD)-(b%MOD)+MOD)%MOD;}
int power(int x, unsigned int y, int p=MOD)  
{  
    if(y==0)
    {
        return 1;
    }
    int ans=power(x,y/2,p);
    if(y%2)
    {
        int z=((((ans*ans)%p)*x)%p);
        return z;
    }
    else
    {
        int z=(ans*ans)%p;
        return z;
    }
} 


int solve()
{
    int n,k;
    cin>>n>>k;
    vi v(n);
    f(n)
        cin>>v[i];
    vector<int> dp(n+1,INT_MAX);
    dp[0]=0;
    for(int i=1;i<n;i++)
    {
        int x=i-k;
        int y=0;
        x=max(y,x);
        int j=i-1;
        while(j>=x)
        {
            int f=abs(v[i]-v[j]);
            dp[i]=min(dp[j]+f,dp[i]);
            j--;
        }
    }
    return dp[n-1];

}
/********************************************/
signed main()
{   
    speed
    int t=1;
    //cin>>t;
    while(t--)
    {
        cout<<solve()<<endl;
    }
    return 0;
}


Measured memory_bytes: 3972
class KenkenRace:
    def __init__(self):
        N, A, B, C, D = map(int, input().split())
        S = [str(c) for c in input()]

        self.N = N
        self.A = A
        self.B = B
        self.C = C
        self.D = D
        self.S = S

    def main(self):
        result = False

        # C < D のとき
        if self.C < self.D:
            # クリアできるか確かめる
            result = self.__canClear(self.A, self.C) and self.__canClear(self.B, self.D)

        # D < C のとき
        else:
            # 追い越せるかどうかを確かめる and クリアできるか確かめる
            result = self.__canClear(self.A, self.C) and self.__canClear(self.B, self.D) and self.__canOvertake()

        if result:
            print("Yes")
        else:
            print("No")

    def __canClear(self, start, end):
        isDouble = False
        preObject = ""

        for i in range(start - 1, end):
            c = self.S[i]
            if c == "#" and preObject == "#":
                isDouble = True
                break
            else:
                preObject = c

        return not isDouble

    def __canOvertake(self):
        isTriple = False
        objectCount = 0
        severalCount = 0

        # Bについて検証
        if self.S[self.B - 2] == "." and self.S[self.B] == ".":
            return True

        if self.S[self.B] == "." and self.S[self.B + 1] == ".":
            return True

        # Dについて検証
        if self.S[self.D - 2] == "." and self.S[self.D] == ".":
            return True

        for i in range(self.B - 1, self.D):
            c = self.S[i]
            objectCount += 1

            # 何もない箇所が何連続目か, カウント
            if c == ".":
                severalCount += 1
            else:
                severalCount = 0

            # 3連続で何もなければ追い越し可能か
            if severalCount == 3:
                isTriple = True
                break

        return isTriple


kenkenRace = KenkenRace()
kenkenRace.main()


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

using namespace std;

int N, k;
int arr[54];

int main(){
    scanf("%d %d", &N, &k);
    for(int i = 1; i <= N; ++i){
        scanf("%d", arr + i);
    }
    int ans = -(int)1e9;
    for(int i = 0; i <= N; ++i){
        for(int j = i + 1; j <= N + 1; ++j){
            for(int x = 0; x <= k; ++x){
                if(i == 2 && j == 3 && x == 3){
                    int g = 1;
                }
                int val = 0;
                set < int > st;
                for(int y = 1; y <= min(i, x); ++y){
                    val += arr[y], st.insert(arr[y]);
                }
                int gap = x - min(i, x);
                auto p = st.begin();
                while(gap-- && p != st.end() && *p < 0){
                    val -= *p, ++p;
                }
                st.clear();
                for(int y = N; y >= max(N - k + x + 1, j); --y){
                    val += arr[y]; st.insert(arr[y]);
                }
                gap = k - x - (N - max(N - k + x + 1, j) + 1);
                p = st.begin();
                while(gap-- && p != st.end() && *p < 0){
                    val -= *p, ++p;
                }
                if(val > 14){
                    int g = 1;
                }
                ans = max(ans, val);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll gcd(ll x,ll y){
    if(x<y)swap(x,y);
    if(x%y==0)return y;
    return gcd(y,x%y);
}

int main(){
    int n;
    cin>>n;
    map<string,int> mp;
    string s[n];
    rep(i,n){
        cin>>s[i];
        mp[s[i]]++;
        if(mp[s[i]]>1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,n-1){
        int k=s[i].size();
        if(s[i][k-1]!=s[i+1][0]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

def main():
    N = int(input())
    d = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            ans += d[i] * d[j]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
//constexpr long long MOD = 1000000007;
constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

ll dp[5050][5050];

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,A,B; cin >> N >> A >> B;
    vector<int> p(N);
    rep(i,N) cin >> p[i];

    rep(i,N+1) rep(j,N+1) dp[i][j] = 1e18;
    dp[0][0] = 0;
    rep(i,N) {
        rep(j,N+1) {
            if (dp[i][j]==1e18) continue;
            if (j < p[i]) {
                chmin(dp[i+1][p[i]],dp[i][j]);
                chmin(dp[i+1][j],dp[i][j]+A);
            } else {
                chmin(dp[i+1][j],dp[i][j]+B);
            }

        }
    }

    ll ans = 1e18;
    rep(i,N+1) chmin(ans,dp[N][i]);

    cout << ans << ln;
}


Measured memory_bytes: 200936
while True:
    n = int(input())
    if n == 0 : 
        break
    else :
        A = [0]*(n+10)
        A[0] = 1
        A[1] = 1
        A[2] = 2
        for i in range (3,n+1):
            A[i] = A[i-1] + A[i-2] + A[i-3]
        print(A[n]//3650 + 1) 


Measured memory_bytes: 5592
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  string str;cin>>str;
  int N = str.size();
  int check = 0;
  int index = 0;
  if(N == 2)
  {
    if(str[0] == str[1])
    {
      cout<<1<<" "<<2<<endl;
      return;
    }
  }
  for (int i = 0; i < N-2; i++)
  {
    if(str[i] == str[i+1] || str[i+1] == str[i+2] || str[i] == str[i+2])
    {
      check = 1;
      index = i;
    }
  }
  if(check)
  {
    cout<<index+1<<" "<<index+3<<endl;
  }
  else
  {
    cout<<-1<<" "<<-1<<endl;
  }
  

  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 512
s = input()
a = 0
b = 1
c = 1
d = 2
n = len(s)
ans = 0
while(True):
    if s[a:b] == s[c:d]:
        d += 1
    else:
        a = c
        b = d
        c = b
        d = c + 1
        ans += 1
    if d == n+1:
        break
print(ans+1)


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

using namespace std;

int main() {
    int a[3];
    for (int i = 0; i < 3; ++i) {
        cin >> a[i];
    }
    sort(a, a + 3);
    cout << a[0] << " " << a[1] << " " << a[2] << '\n';
    return 0;
}


Measured memory_bytes: 3108
s = input()

if s[0] != 'A':
  print("WA")
elif s.count("C") != 1:
  print("WA")
elif s[2:-1].count('C') != 1:
  print("WA")
elif not(((s.replace('A','a')).replace('C','c')).islower()):
    print("WA")
else:
    print("AC") 


Measured memory_bytes: 2940
import java.util.Scanner;
import java.util.Arrays;

class Main {
	static StringBuilder sb = new StringBuilder("");
	
	public static void main(String args[]) {
		run();
	}
	public static void run() {
		Scanner scanner = new Scanner(System.in);
		int  num = scanner.nextInt();//要素数
		Node[] nodes = new Node[num];
		boolean[] child = new boolean[num];
		Arrays.fill(child, true);
		
		//要素ごとの親と子の関係構築
		for(int i = 0; i < num; i ++ ){
			int id = scanner.nextInt();
			int left = scanner.nextInt();
			int right = scanner.nextInt();
			if (left != -1){
				child[left] = false;
			}
			if (right != -1){
				child[right] = false;
			}
			nodes[id] = new Node(id, left, right);
		}
		int root = 0;
		for (int i = 0; i < num; i++) {
			if (child[i]) {
				root = i;
			}
		}		
		
		output(nodes,root);//出力関数
		
		scanner.close();
	}
	
	public static void output(Node[] nodes , int root){
	   	//出力
		sb.append("Preorder\n");
		preParse(nodes, root);
 
		sb.append("\nInorder\n");
		inParse(nodes, root);
 
		sb.append("\nPostorder\n");
		postParse(nodes, root);
		System.out.println(sb);
	}
	//先行巡回
	public static void preParse(Node[] nodes, int root) {
		if (root == -1) return;
		
		sb.append(" ").append(root);
		preParse(nodes, nodes[root].left);
		preParse(nodes, nodes[root].right);
	}
	//中間巡回
	public static void inParse(Node[] nodes, int root) {
		if (root == -1) return;
		
		inParse(nodes, nodes[root].left);
		sb.append(" ").append(root);
		inParse(nodes, nodes[root].right);
	}
	//後行巡回
	public static void postParse(Node[] nodes, int root) {
		if (root == -1) return;
 
		postParse(nodes, nodes[root].left);
		postParse(nodes, nodes[root].right);
		sb.append(" ").append(root);
	}
}
class Node{
	public int id;
	public int parent;
	public int left;
	public int right;
	
	public Node(int id, int left, int right) {
		this.id = id;
		this.left = left;
		this.right = right;
	}
	
}



Measured memory_bytes: 26384
#include<stdio.h>

int main(){
  char str[30] = {};
  int n = 0;
  int check[26] = {};
  int i = 0;
  int j = 0;
  int flag = 0;
  char find = 'X';
  int ok = 0;
  int hoge = 0;
  scanf(" %s",str);
  for(i=0;;i++){
    if(str[i] == '\0'){
      break;
    }else{
      n++;
    }
  }
  for(i=0;i<n;i++){
    check[str[i]-'a']=1;
  }
  /*for(i=0;i<26;i++){
    printf("%d",check[i]);
  }*/
  //printf("\n");
  if(n != 26){
    ok = 1;
    for(i=0;i<26;i++){
      if(check[i] == 0){
        find = 'a'+i;
        break;
      }
    }
    str[n] = find;
    str[n+1] = '\0';
    hoge = n+1;
  }else{
    //printf("#");
    for(i=0;24-i>=0;i++){
      if((int)str[25-i] > (int)str[24-i]){
        //printf("#");
        check[str[25-i]-'a'] = 0;
        for(j=str[24-i]+1;j<='z';j++){
          if(check[j-'a'] == 0){
            str[24-i] = j;
            ok = 1;
            hoge = 25-i;
            break;
          }
        }  
      }else{
        check[str[25-i]-'a'] = 0;
        //printf("$");
      }
      if(ok){
        break;
      }
    }
  }
  /*for(i=0;i<26;i++){
    printf("%d",check[i]);
  }*/
  if(ok){
    for(i=0;i<hoge;i++){
      printf("%c",str[i]);
    }
  }else{
    printf("-1");
  }    
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j;
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll ans=0;
    ll dif=0;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            if(a[i]>a[j]) ans++;
            ans%=Mod;
            if(a[i]!=a[j]) dif++;
            dif%=Mod;
        }
    }
    ans*=k;
    ans%=Mod;
    ans+=(((k*(k-1)/2)%Mod)*dif)%Mod;
    ans%=Mod;
    cout<<ans<<endl;
    
    return 0;   
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

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

    int R, G, B;
    std::cin >> R >> G >> B;

    const string YESNO[2] = {"NO", "YES"};
    std::cout << YESNO[(G * 10 + B) % 4 == 0] << std::endl;
}


Measured memory_bytes: 256
//url:
//problem name:

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
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;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long,long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N,D; cin >> N >> D;
    vector<vector<int>> res(N,vector<int>(D));
    REP(i,N) REP(j,D) cin >> res.at(i).at(j);
    int ans = 0;
    REP(i,N-1){
        for(int j = i+1; j < N; j++) {
            //cout << j << endl;
            int dist = 0;
            REP(l,D) dist += (res[i][l]-res[j][l])*(res[i][l]-res[j][l]);
            //cout << dist << endl;
            for(int k = 0; k*k <= 16000; k++) {
                if(dist == k*k) ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


struct UnionFind{
    vector<int> par;
    vector<int> rank;

    UnionFind(int n){
        par.resize(n);
        rank.resize(n);
        rep(i,n){
            par[i]=i;
            rank[i]=0;
        }
    }

    int find(int x){
        if(par[x]==x)
        return x;
        else return par[x] =find(par[x]);
    }

    void unite(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x] <rank[y]){
            par[x] =y;
        }
        else{
            par[y] =x;
            if(rank[x] ==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){
        return find(x) ==find(y);
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,ans=0;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int x,y,z;
        cin>>x>>y>>z;
        x--;y--;
        if(!uf.same(x,y)){
            uf.unite(x,y);
        }
    }
    rep(i,n){
        if(i==uf.find(i)) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;

int n;
int a[maxn];
queue<int>q;
long long ans = 0;

int main(void){
    cin >> n;
    for(int i=1; i<=n; ++i) cin >> a[i];
    sort(a+1, a+1+n);
    q.push(a[n]);
    for(int i=n-1; i>=1; --i) {
        ans += q.front(); q.pop();
        q.push(a[i]); q.push(a[i]);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 5228
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  unordered_map<int, int> pmap;
  int x, n, p;
  cin >> x >> n;
  for (int i = 0; i < n; ++i)
  {
    cin >> p;
    pmap[p]++;
  }

  int cnt = 0;
  while(true)
  {
    if(pmap[x - cnt] == 0)
    {
      cout << x - cnt;
      return 0;
    }
    else if(pmap[x + cnt] == 0)
    {
      cout << x + cnt;
      return 0;
    }
    cnt++;
  }
}


Measured memory_bytes: 3636
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    let line = chunk.toString().split(' ');
    let x = parseInt(line[0]);
    let y = parseInt(line[1]);
    let z = parseInt(line[2]);
    if (x < y && y < z) { 
        console.log("Yes");
    } else {
        console.log("No");
    }
});


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

int main() {
    vector<int> a(5);
    rep(i, 5)
        cin >> a.at(i);
    
    int count = 0;
    int ans = 0;
    for (int i = 10; i > 0; i--) {
       for(int j = 0; j < 5; j++) {
           if ((a.at(j) % 10) == (i %10)) {
                if (count == 4)
                    ans += a.at(j);
                else
                    ans += a.at(j) + (10-i);
               count++;
           }
           if (count == 5)
                break;
       }
    }

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

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
typedef priority_queue<int> p_queue;
typedef long long ll;
ll a,b;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b;
	if(a==b)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
def shakutori(a):
  left =0
  right = 0
  su = 0
  su1 = 0
  ans = 0
  for left in range(len(a)):
    while right<len(a) and su+a[right]==su1^a[right]:
      su +=a[right]
      su1 = su1^a[right]
      right +=1
    ans+=right -left
    if left==right:
      right+=1
    else:
      su -=a[left]
      su1 ^= a[left]
  return ans
N = int(input())
A = [int(x) for x in input().split()]
print(shakutori(A))

Measured memory_bytes: 24424
import numpy as np
n = int(input())
a = list(map(int,input().split()))
line = np.ndarray((n,2),np.int64)
for i in range(n):
  line[i][0] = i + 1
  line[i][1] = a[i]

s = sorted(line,key=lambda x:x[1])
for i in range(n):
  print(s[i][0])

Measured memory_bytes: 35876
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch NotDivisible | diff NotDivisible.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address NotDivisible.cpp && ./a.out

/*

 6/14/2020

 5:11-5:22 AC

 */

const int MAX_N=1e6+1;
int A[MAX_N];
int N;

vector<LL> divisors(LL N) {
  assert(N>=1);
  vector<LL> res;
  for(LL p=1; p*p<=N; ++p) if(N%p==0) {
    res.push_back(p);
    if(p!=N/p) res.push_back(N/p);
  }
  sort(res.begin(),res.end());
  return res;
}

void solve() {
  VI viz(1e6+1,0);
  map<int,int> cnt;
  REP(i,N) cnt[A[i]]++;
  sort(A,A+N);
  int res=0;

  REP(i,N) {
    int a=A[i];
    if(viz[a]) continue;
    int b=a;
    while(b<SZ(viz)) viz[b]=true,b+=a;
    if(cnt[a]==1)++res;
  }
  cout<<res<<endl;
}

void solve_org() {
  map<int,int> cnt;
  REP(i,N) cnt[A[i]]++;
  int res=0;
  REP(i,N) {
    int a=A[i];
    cnt[a]--;
    vector<LL> ds=divisors(a);
    bool ok=true;
    FORR(d,ds) if(cnt.count(d)&&cnt[d]>0) ok=false;
    //if(ok) dump(i,a);
    res+=ok;
    cnt[a]++;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>N;
  REP(i,N) cin>>A[i];
  solve();

  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B;
int C[12][12];
int D[101][101];
int DX[12][12];
int DY[12][12];
int NV;
int V[303][303];

int K=100;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(V);
	
	cin>>A>>B;
	for(x=1;x<=A;x++) {
		for(y=1;y<=B;y++) {
			cin>>C[x][y];
		}
	}
	
	vector<int> Xs,Ys;
	NV=1;
	Xs.push_back(NV);
	FOR(i,K) {
		V[NV][NV+1]=-2;
		NV++;
		Xs.push_back(NV);
	}
	NV++;
	Ys.push_back(NV);
	FOR(i,K) {
		V[NV+1][NV]=-3;
		NV++;
		Ys.push_back(NV);
	}
	
	for(x=0;x<=K;x++) {
		for(y=0;y<=K;y++) {
			int ret=0;
			for(i=1;i<=A;i++) {
				for(j=1;j<=B;j++) {
					ret=max(ret,C[i][j]-x*i-y*j);
				}
			}
			D[x][y]=V[Xs[x]][Ys[y]]=ret;
		}
	}
	
	for(i=1;i<=A;i++) {
		for(j=1;j<=B;j++) {
			int mi=1010;
			for(x=0;x<=K;x++) {
				for(y=0;y<=K;y++) {
					mi=min(mi,x*i+j*y+D[x][y]);
				}
			}
			if(mi!=C[i][j]) return _P("Impossible\n");
			
		}
	}
	
	
	
	int cnt=0;
	FOR(x,303) FOR(y,303) if(V[x][y]!=-1) cnt++;
	cout<<"Possible"<<endl;
	cout<<NV<<" "<<cnt<<endl;
	FOR(x,303) FOR(y,303) if(V[x][y]!=-1) {
		cout<<x<<" "<<y<<" ";
		if(V[x][y]==-2) cout<<"X"<<endl;
		if(V[x][y]==-3) cout<<"Y"<<endl;
		if(V[x][y]>=0) cout<<V[x][y]<<endl;
	}
	cout<<Xs[0]<<" "<<Ys[0]<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

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

		int c = (a + b);
		int d = (a - b);
		int e = (a * b);

		System.out.println(Math.max(Math.max(c, d), e));
	}
}

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

int main() {
	int n;
	std::cin >> n;
	string s;
	std::cin >> s;
	if (n % 2 != 0) {
		std::cout << "No";
	}
	else {
		int mid = n / 2;
		bool res = false;
		for (int i = 0; i < mid; i++) {
			if (s[i] != s[mid + i]) {
				res = true;
			}
		}
		(res == false) ? std::cout << "Yes" : std::cout << "No";
	}
}

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

int main(){
    int f = -1, e, i;
    string s;
    cin >> s;
    for(i=0; i<s.length(); i++){
        if(f == -1 && s[i] == 'A'){
            f = i;
        }
        if(s[i] == 'Z'){
            e = i;
        }
    }
    cout << e - f + 1;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>L(n);
	rep(i, n)cin >> L[i];
	sort(L.begin(), L.end());
	int ans = 0;
	rep(b, n)rep(a, b) {
		int ab = L[a] + L[b];
		int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
		int l = b + 1;
		ans += max(0, r - l);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
x,y = map(str,input().split())
a = {'1':300000,'2':200000,'3':100000}
if int(x) > 3 or int(y) > 3:
    if int(x) <= 3:
        print(a[x])
    elif int(y) <= 3:
        print(a[y])
    else:
        print(0)
else:
    if x == y == '1':
        print(1000000)
    else:
        print(a[x]+a[y])

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

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

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"

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


int a;

int main() {
	cin >> a;
	if (a < 1200)cout << "ABC\n";
	else cout << "ARC\n";
	return 0;
}



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

int main() {
    int N;
    long long T;
    cin >> N >> T;

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

    long long ans = 0;
    long long time = 0;
    for (int i = 1; i < N; i++) {
        long long dt = t[i] - t[i - 1];
        if (dt < T) {
            ans += dt;
        }
        else {
            ans += T;
        }
    }

    cout << ans + T << endl;
}

Measured memory_bytes: 1792
import sys
sys.setrecursionlimit(10**7)
n,m=map(int,input().split())
a=[[] for i in range(n)]
for i in range(m):
    u,v,w=map(int,input().split())
    a[u-1].append((v-1,w))
    a[v-1].append((u-1,w))
b=[None for i in range(n)]
def k(v,dis):
    b[v]=dis
    for next_v,w in a[v]:
        if b[next_v]!=None:
            continue
        if w%2==0:
            k(next_v,dis)
        else:
            k(next_v,1-dis)
c2=0
for i in range(n):
    if b[i]==None:
        k(i,0)
        c2+=1
print(c2)

Measured memory_bytes: 122984
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
typedef long long ll;
int n,a[N];
int z[N];
bool check(int x){
    for(int i=1;i<=2*n-1;i++){
        z[i]=a[i]>=x;
    }
    for(int i=0;i<n-1;i++){
        int s0=0,s1=0;
        if(z[n-i]==1&&z[n-i-1]==1)
            return 1;
        if(z[n-i]==0&&z[n-i-1]==0)
            return 0;
        if(z[n+i]==1&&z[n+i+1]==1)
            return 1;
        if(z[n+i]==0&&z[n+i+1]==0)
            return 0;
    }
    return z[1];
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=2*n-1;i++)
        scanf("%d",&a[i]);
    int l=1,r=2*n;
    while(l+1<r){
        int mid=(l+r)>>1;
        if(check(mid))
            l=mid;
        else
            r=mid;
    }
    printf("%d\n",l);
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 400010
const ll MOD = 998244353;
const ll INF = 1e15;

ll A[MAXN];
ll B[MAXN];
ll a,b,m;
ll x,y,z;
ll amin=INF;
ll bmin=INF;

int main(){
	cin>>a>>b>>m;
	for (int i=1;i<=a;++i){
		cin>>A[i];
		amin = min(amin,A[i]);
	}
	for (int i=1;i<=b;++i){
		cin>>B[i];
		bmin = min(bmin,B[i]);
	}
	ll ans = amin+bmin;
	while (m--){
		cin>>x>>y>>z;
		ans = min(ans, {A[x]  +B[y] - z});
	}
	cout<<ans;
}

Measured memory_bytes: 3072
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]

n,m = MI()
count = 0
if n>1:
    count += n*(n-1)/2
if m>1:
    count += m*(m-1)/2
print(int(count))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine();
        String[] tmpV = sc.nextLine().split(" ");
        String[] tmpC = sc.nextLine().split(" ");

        int max = 0;
        for (int i = 0; i<N; i++) {
            int t = Integer.valueOf(tmpV[i])-Integer.valueOf(tmpC[i]);
            if (0<t) {
                max += t;
            }
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
vector<pair<int,pair<int,int>>>a;
multiset<int>s;
int main()
{
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
	{
		int s,t,x;
		scanf("%d%d%d",&s,&t,&x);
		a.push_back(make_pair(s-x,make_pair(1,x)));
		a.push_back(make_pair(t-x,make_pair(-1,x)));
	}
	sort(a.begin(),a.end());
	int i=0;
	while(q--)
	{
		int d;
		scanf("%d",&d);
		while(a[i].first<=d&&i<a.size())
		{
			if(a[i].second.first==1)
				s.insert(a[i].second.second);
			else
				s.erase(a[i].second.second);
			i++;
		} 
		if(s.size())
			printf("%d\n",*s.begin());
		else
			printf("-1\n");
	}
	return 0;
}


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

int A,B;

int main()
{
  cin >> A >> B;
  int ans = (B % A == 0) ? A + B : B - A;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!(a: f64, b: f64, h: f64, m: f64);
    let h2 = h + m / 60.0;
    let kaku_h = 30.0 * h2;
    let kaku_m = 6.0 * m;
    let mut kaku: f64 = (kaku_h - kaku_m).abs();
    if kaku > 180.0 {
        kaku = 360.0 - kaku;
    }
    let kaku = kaku.to_radians();
    println!("{:.12}", (a * a + b * b - 2.0 * a * b * kaku.cos()).sqrt());
}


Measured memory_bytes: 3012
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

int mod_pow(ll a, ll n, int m = MOD) {
  int res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % m;
    a = a * a % m;
    n >>= 1;
  }
  return res;
}

int mod_comb(ll n, ll r, int m = MOD) {
  ll x = 1, y = 1;
  rep(i, r) {
    x = x * (n - i) % m;
    y = y * (r - i) % m;
  }
  return x * mod_pow(y, MOD - 2) % MOD;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = mod_pow(2, n) - 1;
  ans = (ans - mod_comb(n, a) + MOD) % MOD;
  ans = (ans - mod_comb(n, b) + MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 256