akhauriyash/Code-Regression huggingface dataset:
// Strings with the Same Length

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>
#include <stdio.h>
#include <string.h>
#include <initializer_list>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <set>

using namespace std;

int main ()
{
    int N;
    string S, T;

    cin >> N;
    cin >> S >> T;

    string result;

    for (int i = 0; i < N *2; i++) {
        if (i % 2 == 0) {
            // 偶数
            char c = S[(int)i/2];
            result.push_back(c);
        }
        else {
            // 奇数
            char c = T[(int)i/2];
            result.push_back(c);
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstring>
#include<functional>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)

using namespace std;

int main(){
	long int N,M,L,R,l(0),r(100000);
	cin >> N >> M;
	rep(i,0,M){
		cin >> L >> R;
		if(L > l) l = L;
		if(R < r) r = R;
	}
	if(0 <= r - l + 1) cout << r - l + 1 << endl; else cout << "0" << endl;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

const int MAX = 1111;
int n,k;
int t[MAX][MAX];
int sp[MAX][MAX];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n;
  cin >> k;
  int sum1 = 0;
  int sum2 = 0;
  R(i,n){
    int x,y;
    char c;
    cin >> x >> y >> c;
    int pom = ((x / k) + (y / k) + (c == 'B')) % 2 ? 1 : -1;
    t[x%k][y%k] += pom;
    if(pom == 1)
      sum1 ++;
    else
      sum2 ++;
    
  }
  R(i,k)R(j,k){
    sp[i+1][j+1] = sp[i+1][j] + sp[i][j+1] + t[i][j] - sp[i][j];
  }
//   R(i,k+1){
//     R(j,k+1){
//       cerr << sp[i][j] << " ";
//     }
//     cerr << "\n";
//   }
  int res = 0;
  R(i,k)R(j,k){
    int pom = sp[i][k] + sp[k][j] - 2 * sp[i][j];
//     debug(pom);
    maxi(res,sum2 + pom);
    maxi(res,sum1 - pom);
  }
  cout << res << "\n";
}


Measured memory_bytes: 18688
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int i,j,n,k,a[262144],r=0;
    char s[131072];
    scanf("%d%d%s",&n,&k,&s);
    for(i=0;i<n+k+1;i++){
        if(i==n && s[i]!='-'){printf("No\n");return 0;}
        if(i!=n && s[i]=='-'){printf("No\n");return 0;}
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
A, B, K  = map(int, input().split())
a = A
b = B
for i in range(K):
    if i%2 == 0:
        if a % 2 == 1:
            a -= 1
        a //= 2
        b += a
    else:
        if b % 2 == 1:
            b -= 1
        b //= 2
        a += b
print(a, b)

Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
    int num=0;
    int i,sum=0;
    char str[100000];
    scanf("%s",str);
    while(str[num]!='\0')
    {
        num++;
    }
    for(i=0;i<(num-1);i++)
       {
          if(str[i]!=str[i+1])
             continue;
          if(str[i]==str[i+1])
          {
              sum++;
              if(str[i]=='0')
                  str[i+1]='1';
              if(str[i]=='1')
                  str[i+1]='0';
          }
       }
    printf("%d",sum);
    return 0;
}


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

int main()
{
	int X, Y;
	cin >> X >> Y;

	if (Y % 2 == 0 && 2 * X <= Y && Y <= 4 * X) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3624
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int m1=sc.nextInt();
        int d1=sc.nextInt();
        int m2=sc.nextInt();
        int d2=sc.nextInt();
        if(d2==1){
          System.out.println("1");
        }else{
          System.out.println("0");
        }
	}
}


Measured memory_bytes: 25044
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int tspl[1000][4],tt[1260];
int N,M,t,ts,te,r,n,m,q,i,j,k;

int main(){
	while(0<=scanf("%d%d",&N,&M)){
		if(N==0 && M==0){
			break;
		}
				
		scanf("%d",&r);
		
		for(q=0;q<r;q++){
			scanf("%d%d%d%d",&tspl[q][0],&tspl[q][1],&tspl[q][2],&tspl[q][3]);
		}
		
		scanf("%d",&q);
		
		for(n=0;n<q;n++){
			scanf("%d%d%d",&ts,&te,&m);

			for(t=0;t<1260;t++){
				tt[t]=0;
			}
			
			for(t=0;t<r;t++){
				if(tspl[t][2]==m && tspl[t][3]==1){
					for(j=t+1;j<r;j++){
						if(tspl[j][1]==tspl[t][1]){
							for(k=tspl[t][0];k<tspl[j][0];k++){
								tt[k]=1;
							}
							break;
						}
					}
				}
			}
			
			j=0;
			for(t=ts;t<te;t++){
				if(tt[t]==1){
					j++;
				}
			}
			
			printf("%d\n",j);
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}
int main() {
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  long long waru_a_c=a/c;
  long long waru_b_c=b/c;
  long long waru_a_cd=a/lcm(c,d);
  long long waru_a_d=a/d;
  long long waru_b_d=b/d;
  long long waru_b_cd=b/lcm(c,d);
  long long kotae=b-a+1-waru_b_c + waru_a_c - waru_b_d + waru_a_d + waru_b_cd - waru_a_cd;
  if(a%c==0)kotae--;
  if(a%d==0)kotae--;
  if(a%c==0&&a%d==0)kotae++;
  //cout<<" "<<waru_b_c<<" "<<lcm(c,d)<<" "<<waru_b_cd<<" "<<waru_a_cd<<endl;
  cout<<kotae<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  ll xsa=x2-x1,ysa=y2-y1;
  cout<<x2-ysa<<" "<<y2+xsa<<" ";
  x1=x2;y1=y2;
  x2-=ysa;y2+=xsa;
  xsa=x2-x1;ysa=y2-y1;
  cout<<x2-ysa<<" "<<y2+xsa<<endl;
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> xs(n); 
  rep(i, n) {
    cin >> xs.at(i);
  }

  sort(xs.begin(), xs.end());
  p(xs[xs.size()-1]-xs[0]);
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << std::setprecision(10) << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()

signed main() {
	int n;
	std::cin >> n;
	double sum = 0;
	rep(i,n) {
		double a;
		std::cin >> a;
		sum+=1/a;
	}
	print(1/sum);
	return 0;
}


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

using namespace std;

int main() {
  typedef unordered_set<string> set_t;
  set_t dict;
  int n;
  string cmd; //command
  string word; //word to store
  unordered_set<string>::const_iterator got; //for find

  cin >> n; // number of inputs
  for (int i = 0; i < n; ++i) {
    cin >> cmd >> word;

    if (cmd[0] == 'i') { // if insert
      dict.insert(word);
    } else {
      got = dict.find(word);
      if (got == dict.end()) {
	cout << "no" << endl;
      } else {
	cout << "yes" << endl;
      }
    }
  }
}
	 

Measured memory_bytes: 30564
#include<cstdio>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
using namespace std;
long long a[210000];
int main(){
	int k,n,i;
	scanf("%d%d",&n,&k);
	long long ans=0;
	for(i=1;i<=n;i++){
		int x;
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	for(i=1;i<=n-k;i++){
		ans+=a[i];
	}
	printf("%lld\n",ans);
}

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

const long long INF = 1LL << 60;
long long dp[100010];
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true; } return false; }

int main()
{
    int N, K; cin >> N >> K;
    int h[N];
    for (int i = 0; i < N; i++) cin >> h[i];
    for (int i = 0; i < 100010; i++) dp[i] = INF;

    dp[0] = 0;
    for (int i = 1; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            if (i-j >= 0) {
                chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
            }
        }
    }

    cout << dp[N-1] << endl;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<double> VD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	int a, p;
	cin >> a >> p;
	p += 3 * a;
	cout << p / 2;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        String[] params = in.nextLine().split(" ");
        int n = Integer.parseInt(params[0]);
        int k = Integer.parseInt(params[1]);
        params = in.nextLine().split(" ");
        int count = 0;
        for( int i = 0 ; i < n ; i++ ){
            int h = Integer.parseInt(params[i]);
            if( k <= h ){
                count++;
            }
        }

        System.out.println(count);

    }

}


Measured memory_bytes: 34600
#include<stdio.h>
 
int main(void){

  int i,n;  
  scanf("%d",&n);
  
  double x[n],m=0;
  char u[n][4];
  
  for(i=0;i<n;i++){
    scanf("%lf %s",&x[i],u[i]);
    if(u[i][0]=='J')
      m+=x[i]; 
    if(u[i][0]=='B')
      m+=380000*x[i];
  }
  
  printf("%f\n",m);
   
  return 0;
}

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

int main(int argc, char *argv[]){
    unsigned int N;
    std::cin >> N;
    std::string string[N];
    std::map<std::string, int>map;
    for(auto &s : string){
        std::cin >> s;
        std::sort(s.begin(),s.end());
        map[s]++;
    }

    long int anagrams = 0;
    long int count;
    for(auto &hist : map){
        count = hist.second;
        if(count==1){ continue; }
        anagrams += ((count)*(count-1))/2;
    }
    std::cout << anagrams << std::endl;
    return 0;
}


Measured memory_bytes: 18176
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long ans = A*B/2;
		Console.WriteLine(ans);
	}
}

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

int main()
{
  int a, b, c, d, e, f, g, h;
  while (cin >> a >> b >> c >> d >> e >> f >> g >> h)
    cout << max(a+b+c+d, e+f+g+h) << endl;
  return 0;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    string s;
    cin >> s;
    bool ok = true;
    repeat(i, 1, (int)s.size()) {
        if (s[i - 1] == s[i])
            ok = false;
    }
    if (ok)
        out("Good");
    else
        out("Bad");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n;
  std::cin>>n;
  std::vector<double> v(n);
  for(int i = 0;i<n;i++){
    std::cin >> v[i];
  }
  std::sort(v.begin(), v.end() );
  for(int i=0;i<n-1;i++){
    v[i+1] = (v[i] + v[i+1])/2.0;
  }
  std::cout << v[n-1] << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define max_ans 2000000
#define INF max_ans+1
#define max_n 200000
using namespace std;
struct fl{
	int x,y,key;
	char u;
};
bool cmp1(const fl&x,const fl&y){
	if(x.x==y.x)
		return x.y<y.y;
	return x.x<y.x;
}
bool cmp2(const fl&x,const fl&y){
	if(x.y==y.y)
		return x.x<y.x;
	return x.y<y.y;
}
bool cmp3(const fl&x,const fl&y){
	if(x.key==y.key)
		return x.x<y.x;
	return x.key<y.key;
}
fl p[max_n+1];
template<typename T1,typename T2>void minify(T1&x,const T2&y){
	y<x&&(x=y);
}
int main(){
	int n;
	int ans=INF;
	scanf("%d",&n);
	for(int i=0; ++i<=n; scanf("%d%d %c",&p[i].x,&p[i].y,&p[i].u));
	stable_sort(p+1,p+n+1,cmp1),p[0].x=p[0].y=-1;
//	for(int i=0; ++i<=n; printf("*%d %d %c\n",p[i].x,p[i].y,p[i].u));
	for(int i=0,lstu=-INF; ++i<=n; )
		if(p[i].x!=p[i-1].x)
			lstu=p[i].u=='U'?p[i].y:-INF;
		else
			if(p[i].u=='U')
				lstu=p[i].y;
			else
				if(p[i].u=='D')
					minify(ans,(p[i].y-lstu)*5);
	stable_sort(p+1,p+n+1,cmp2);
	for(int i=0,lstr=-INF; ++i<=n; )
		if(p[i].y!=p[i-1].y)
			lstr=p[i].u=='R'?p[i].x:-INF;
		else
			if(p[i].u=='R')
				lstr=p[i].x;
			else
				if(p[i].u=='L')
					minify(ans,(p[i].x-lstr)*5);
	for(int i=0; ++i<=n; p[i].key=p[i].y-p[i].x);
	stable_sort(p+1,p+n+1,cmp3);
	for(int i=0,lstu=-INF,lstr=-INF; ++i<=n; ){
		if(p[i].key!=p[i-1].key)
			lstu=lstr=-INF;
		switch(p[i].u){
			case 'U':
				lstu=p[i].x;
				break;
			case 'R':
				lstr=p[i].x;
				break;
			case 'L':
				minify(ans,(p[i].x-lstu)*10);
				break;
			case 'D':
				minify(ans,(p[i].x-lstr)*10);
				break;
		}
	}
	for(int i=0; ++i<=n; p[i].key=p[i].y+p[i].x);
	stable_sort(p+1,p+n+1,cmp3);
	for(int i=0,lstd=-INF,lstr=-INF; ++i<=n; ){
		if(p[i].key!=p[i-1].key)
			lstd=lstr=-INF;
		switch(p[i].u){
			case 'D':
				lstd=p[i].x;
				break;
			case 'R':
				lstr=p[i].x;
				break;
			case 'L':
				minify(ans,(p[i].x-lstd)*10);
				break;
			case 'U':
				minify(ans,(p[i].x-lstr)*10);
				break;
		}
	}
	if(ans==INF)
		puts("SAFE");
	else
		printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 7880
#include <iostream>
#include <vector>
#include <set>
using namespace std;
#define maxs 100000

vector<int> g[maxs];
int n;
bool visited[maxs];
int prenum[maxs],parent[maxs],lowest[maxs],timer;

void dfs(int current,int prev){
  prenum[current]=lowest[current]=timer;
  timer++;
  visited[current]=true;
  int next;
  for(int i=0;i<g[current].size();i++){
    next=g[current][i];
    if(!visited[next]){
      parent[next]=current;
      dfs(next,current);
      lowest[current]=min(lowest[current],lowest[next]);
    }else if(next!=prev){
      lowest[current]=min(lowest[current],prenum[next]);
    }
  }
}

void art_points(){
  for(int i=0;i<n;i++){
    visited[i]=false;
  }
  timer=1;
  dfs(0,-1);

  set<int> ap;
  int np=0;
  for(int i=1;i<n;i++){
    int p=parent[i];
    if(p==0)np++;
    else if(prenum[p]<=lowest[i])ap.insert(p);
  }
  if(np>1)ap.insert(0);
  for(set<int>::iterator it =ap.begin();it!=ap.end();it++)
    cout<<*it<<endl;
}

int main(){
  int m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int s,t;
    cin>>s>>t;
    g[s].push_back(t);
    g[t].push_back(s);
  }
  art_points();
  return 0;
}

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


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

  vector<int> p( n ) ;
  rep( i, n ) cin >> p[i];

  int countWrong = 0 ;
  rep(i, n) {
    if ( p[i] != i+1 ) countWrong++ ;
  }
  if ( countWrong == 0 || countWrong == 2 ) puts( "YES" ) ;
  else                puts( "NO" ) ;
  return 0 ;
}



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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
   int n,i,a[100000],m;
    
   scanf("%d",&n);
   for (i=0;i<n;i++) scanf("%d",&a[i]);
   qsort(a,n,sizeof(int),asc);
   m=a[n-1]-a[0];
   for (i=1;i<n-1;i++)
      if (a[i]>0) m+=a[i];
      else        m-=a[i];
   printf("%d\n",m);
   for (i=1;i<n-1;i++)
      if (a[i]>0) {
         printf("%d %d\n",a[0],a[i]);
         a[0]-=a[i];
      } else {
         printf("%d %d\n",a[n-1],a[i]);
         a[n-1]-=a[i];
      }
   printf("%d %d\n",a[n-1],a[0]);
   return 0;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(int i=0;i<n;i++)
#define repf(i,f,n) for(int i=f;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


const int64_t CYCLES_PER_SEC = 2800000000;

struct Timer {
  int64_t start;
  Timer() { reset(); }
  void reset() { start = getCycle(); }
  void plus(double a) { start -= (a * CYCLES_PER_SEC); }
  inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
  inline int64_t getCycle() {
    uint32_t low, high;
    __asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
    return ((int64_t)low) | ((int64_t)high << 32);
  }
};

class XorShift {
public:
  unsigned int x, y, z, w;
  double nL[65536];

  XorShift()
  {
    init();
  }

  void init()
  {
    x = 314159265; y = 358979323; z = 846264338; w = 327950288;
    double n = 1 / (double)(2 * 65536);
    for (int i = 0; i < 65536; i++) {
      nL[i] = log(((double)i / 65536) + n);
    }
  }
  void setSeed(int seed) {
    x = 314159265; y = 358979323; z = 846264338; w = 327950288 + seed;
    for (int i = 0; i < 500; i++) {
      next();
    }
  }
  inline unsigned int next()
  {
    unsigned int t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
  }

  inline double nextLog() {
    return nL[next() & 0xFFFF];
  }

  inline int nextInt(int m)
  {
    return (int)(next() % m);
  }


  int nextInt(int min, int max)
  {
    return min + nextInt(max - min + 1);
  }


  double nextDouble()
  {
    return (double)next() / ((long long)1 << 32);
  }


};



// グローバル変数
Timer timer;
XorShift rnd;

int D;
vector<int> c(26,0);
vector<vector<int>> s;

vector<int> bestState;
int bestScr;



void input(){
  cin>>D;
  rep(i,26) cin>>c[i];
  s.resize(D, vector<int>(26,0));
  rep(i,D)rep(j,26) cin>>s[i][j];

  bestState.resize(D);
};

void output(){
  for(auto e:bestState) cout<<e<<endl;
};

int eval(){
  return 1;
}

void init(){
  vector<int> last(26,-1);
  rep(i,D){
    int mxVal = 0;
    int mxIdx = 0;
    rep(j,26){
      if(chmax(mxVal, s[i][j] + c[j]*(i - last[j]))) mxIdx = j;
    }
    bestState[i] = mxIdx + 1;
    last[mxIdx] = i;
  }
}

void rndInit(){
  rep(i,D) bestState[i] = rnd.nextInt(1,26);
}


void solveClimb(){
  double ti;
  double T;
  double T0 = 100; // 調整する
  double rem;


  double TIMELIMIT = 1.98;
  double st = timer.get();

  while(true){
    ti = timer.get();

    if(ti > TIMELIMIT){
      // cout<<"break"<<endl;
      break;
    }
    rem = (TIMELIMIT - ti) / (TIMELIMIT - st);
    T = rem * T0;

    cout<<ti<<" "<<rem<<endl;

  }

};





int main() {
  cout<<fixed<<setprecision(12);

  input();

  init();
  // rndInit();

  // solveClimb();
  output();

;






}


Measured memory_bytes: 4604
N = int(input())
s = []
for i in range(N):
  s.append(input())
M = int(input())
t = []
for i in range(M):
  t.append(input())
  
c = list(set(s))
ans = 0
for i in range(len(c)):
  ans = max([ans, s.count(c[i])-t.count(c[i])])
  
print(ans)

Measured memory_bytes: 9204
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int a,b,c;
  C3(a,b,c);
  if(a == b)
    P(c);
  else{
    if(a == c)
      P(b);
    else
      P(a);

  }
    
  ret 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define QSIZE 10000
char q[QSIZE][11];
int qh=0;
int qt=0;

int enQ(char str[]){
	memcpy(q[qt],str,11);
	qt=(qt+1)%QSIZE;
	return (qt-qh+QSIZE)%QSIZE;
}

int deQ(char str[]){
	memcpy(str,q[qh],11);
	qh=(qh+1)%QSIZE;
	return (qt-qh+QSIZE)%QSIZE;
}
int Qlen(){
	return (qt-qh+QSIZE)%QSIZE;
}

int hoge(char str[]){
	int i;
	for(i=0;str[i]!='\0';i++){
		switch(str[i]){
			case 'r':
				str[i]='0';
				break;
			case 'g':
				str[i]='1';
				break;
			case 'b':
				str[i]='2';
		}
	}
	return i;
}

int ato3(char str[]){
	int i;
	int keta=1;
	int r=0;
	for(i=strlen(str)-1;i>=0;i--){
		r+=(str[i]-'0')*keta;
		keta*=3;
	}
	return r;
}

main(){
	char str[11],str2[11];
	char goal[3][11];
	char musi[177147];
	int N;
	int len;
	int sec;
	int i,j;
	while(scanf("%s",&str)==1){
		if(str[0]=='0')
			break;
		qh=qt=0;
		memset(musi,-1,177147);
		len=hoge(str);
		N=enQ(str);
		sec=0;
		musi[ato3(str)]=sec;
		for(i=0;i<3;i++){
			for(j=0;j<len;j++)
				goal[i][j]=i+'0';
			goal[i][j]='\0';
		}
		while(1){
			if(musi[ato3(goal[0])]!=-1){
					printf("%d\n",sec);
					break;
			}
			if(musi[ato3(goal[1])]!=-1){
					printf("%d\n",sec);
					break;
			}
			if(musi[ato3(goal[2])]!=-1){
					printf("%d\n",sec);
					break;
			}
			if(N==0){
				puts("NA");
				break;
			}
			sec++;
			for(j=0;j<N;j++){
				deQ(str);
				for(i=0;i<len-1;i++){
					if(str[i]!=str[i+1]){
						strcpy(str2,str);
						str2[i]=str2[i+1]=3+3*'0'-str[i]-str[i+1];
						if(musi[ato3(str2)]==-1){
							musi[ato3(str2)]=sec;
							enQ(str2);
						}
					}
				}
			}
			N=Qlen();
		}
	}
	return 0;
}

Measured memory_bytes: 844
#include<stdio.h>
int main(void)
{
	int a,b,c,d,x,y,z;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<c){
		x=c;
	}
	else{
		x=a;
	}
	if(b>d){
		y=d;
	}
	else{
		y=b;
	}
	z=y-x;
	if(z<0){
		printf("0\n"); 
	}
	else{
		printf("%d\n",z);
	}
	return 0;
}


Measured memory_bytes: 128
l = list(input().split())
s = []
for p in l:
    if p == '+':
        s.append(s.pop() + s.pop())
    elif p == '-':
        s.append(-(s.pop() - s.pop()))
    elif p == '*':
        s.append(s.pop() * s.pop())
    else:
        s.append(int(p))

print(s.pop())



Measured memory_bytes: 5596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,m;
bool a[510][510],b[510][510];
int main(){
	int i,j;char s[510];
	n=read();m=read();
	for(i=1;i<=n;i++){
		scanf("%s",s);
		for(j=1;j<=m;j++){
			if(s[j-1]=='#') a[i][j]=b[i][j]=1;
		}
	}
	for(i=1;i<=n;i++) a[i][1]=1,b[i][m]=1;
	for(i=1;i<=n;i++){
		for(j=2;j<m;j++){
			if(i%2) a[i][j]=1;
			else b[i][j]=1;
		}
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(a[i][j]) putchar('#');
			else putchar('.');
		}
		putchar('\n');
	}
	putchar('\n');
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			if(b[i][j]) putchar('#');
			else putchar('.');
		}
		putchar('\n');
	}
}

Measured memory_bytes: 1280
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define hi(x) ((x)>>16)
#define lo(x) ((x)&0xffff)

struct comp{
    bool operator()(const unsigned a, const unsigned b){return hi(a)*lo(a) < hi(b)*lo(b);}
};

int main(){
	int n,w,d;
	for(;scanf("%d%d%d",&n,&w,&d),w;){
	vector<unsigned> v;
	v.push_back((w<<16)+d);
	while(n--){
		int p, s, state=0;
		scanf("%d%d", &p, &s);
		p--;
		s%=hi(v[p])+lo(v[p]);
		
		unsigned x=hi(v[p]), y=lo(v[p]), _x=0, _y=0;
		while(s--){
			switch(state){
				case 0:{
					_x++;
					if(_x==x)state=1;
					break;
				}
				case 1:{
					_y++;
					break;
				}
			}
		}
		unsigned x1, x2, y1, y2;
		switch(state){
			case 0:{
				x1=_x;x2=x-_x;
				y1=y2=y;
				break;
			}
			case 1:{
				x1=x2=x;
				y1=_y;y2=y-_y;
				break;
			}
		}
		
		v.erase(v.begin()+p);
		if(x1*y1>x2*y2){
			v.push_back((x2<<16)+y2);
			v.push_back((x1<<16)+y1);
		}else{
			v.push_back((x1<<16)+y1);
			v.push_back((x2<<16)+y2);
		}
	}
	
	sort(v.begin(), v.end(), comp());
	while(v.size()){
		printf("%d", hi(v[0])*lo(v[0]));
		v.erase(v.begin());
		if(v.size())printf(" ");
	}
	printf("\n");
	}
}

Measured memory_bytes: 0
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    println!("{}", n * n * n);
}


Measured memory_bytes: 4352
//============================================================================
// Name        : alds1_4_d_allocation.cpp
// Author      : lovesaemi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

#define MAX 100000

typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P){
	int i = 0;
	for (int j = 0;j<k;j++){
		llong s = 0;
		while(s + T[i] <= P) {
			s += T[i];
			i++;
			if(i == n) {
				return n;
			}
		}
	}
	return i;
}

int solve(){
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if(v >= n) right = mid;
		else left = mid;
	}
	return right;
			
}

int main() {
	cin >> n >> k;
	for(int i = 0;i<n;i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3864
N, M = map(int, input().split())
ks_mat =  [list(map(int, input().split())) for i in range(M)]
p = list(map(int, input().split()))
import itertools
OnOff_list = itertools.product([True,False],repeat=N)
ans = 0
for OnOff in OnOff_list:
    for i in range(M):#M個の電球のうち，i個目のものがついているか確認
        c = 0
        for k, j in enumerate(OnOff):
            if j and (k+1 in ks_mat[i][1:]):#スイッチがオンかつ，繋がっている場合はonになっているスイッチとしてカウント
                c += 1
        if not c % 2 == p[i]:#1つでもついていない場合は探索を中止
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 3064
from collections import deque
from heapq import heapify, heappop

n = int(input())
edge = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
c = list(map(int, input().split()))
cc = [-i for i in c]
heapify(cc)

start = None
for i in range(n):
    if len(edge[i]) == 1:
        start = i
        break

visited = [0]*n
q = deque()
q.append((start))
while q:
    now = q.pop()
    if visited[now]:
        continue
    a = heappop(cc)
    visited[now] = -a
    for i in edge[now]:
        if not visited[i]:
            q.append(i)
print(sum(c) - max(c))
print(*visited)

Measured memory_bytes: 59096
//#include<bits/stdc++.h>
#define ll long long
#include <stdio.h>
#include <algorithm>
#pragma GCC optimize(2)
using namespace std;
const int maxn=1e6+1000;
const int INF=1e9+7;
inline ll read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll n,m;
ll num[maxn];
ll gcd(ll a,ll b)
{
    if(!b) return a;
    return gcd(b,a%b);
}
int main()
{
    scanf("%lld",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&num[i]);
    ll lcm=num[1];
    for(int i=2;i<=n;i++)
    {
        ll temp=gcd(lcm,num[i]);
        lcm=lcm*num[i]/temp;
    }
    ll sum=0;
    for(int i=1;i<=n;i++)
        sum+=lcm/num[i];
   // printf("%lld %lld\n",sum,lcm);
    double res=(double)(lcm)*1.0;
    double res1=(double)(sum)*1.0;
    printf("%.6lf\n",res/res1*1.0);
    return 0;
}


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

string N;

int main() {
    cin >> N;

    string ans = "No";
    if (N[0] == N[1] && N[1] == N[2]) ans = "Yes";
    if (N[1] == N[2] && N[2] == N[3]) ans = "Yes";

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){
    vector<int> arr;
    int N;
    cin >> N;

    for(int i=0; i < N; ++i){
        int tmp;
        cin >> tmp;
        arr.push_back(tmp);
    }

    int ans=0;

    for(int i=0; i <N-2; ++i){
        for(int j=i+1; j <N-1; ++j){
            for(int k=j+1; k< N; ++k){
                long long f,s,t;
                f = arr[i];
                s = arr[j];
                t = arr[k];

                if(f == s || s == t || f == t){
                    continue;
                }
                else{
                    long long max = 0;
                    chmax(max,f);
                    chmax(max,s);
                    chmax(max,t);
                    if((f+s+t)>(2*max)){
                        ++ans;
                    }
                }
            }

        }

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

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

long    P( long S, int f, long N) {
        long SS=0;
        if (S>N) return 0;
        if (7==f) SS++;
        SS += P( S*10+3, f|1, N);
        SS += P( S*10+5, f|2, N);
        SS += P( S*10+7, f|4, N);
        return SS;
}

int     main() {
        long N;
        cin >> N;
        cout << P( 0, 0, N) << endl;
        return 0;
}

Measured memory_bytes: 256
from itertools import combinations

l, r = map(int, input().split())

if r - l > 2019:
    r = l + 2019

ans = 2020
comb = combinations(range(l, r+1), 2)
for c in comb:
    ans = min(ans, (c[0]*c[1])%2019)

print(ans)

Measured memory_bytes: 3060
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
B = defaultdict(int)
C = defaultdict(int)

for i in range(N):
  B[A[i]+i+1] += 1
  C[-A[i]+i+1] += 1

ans = 0

for x in B.keys():
  ans += B[x] * C[x]

print(ans)

Measured memory_bytes: 73712
if __name__ == '__main__':
    S = str(input())

    tmp_S = S[2:len(S)-1]
    tmp_S_2 = S[1] + tmp_S.replace('C', '') + S[len(S)-1]

    if S[0] == 'A' and tmp_S.count('C') == 1 and tmp_S_2.islower() == True:
        print('AC')
    else:
        print('WA')

Measured memory_bytes: 3060
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		String pattern[] = {
			"* = ****",
			"* =* ***",
			"* =** **",
			"* =*** *",
			"* =**** ",
			" *= ****",
			" *=* ***",
			" *=** **",
			" *=*** *",
			" *=**** "
		};
		Scanner sc = new Scanner(System.in);
		boolean first = true;
		while (sc.hasNext())
		{
			if (!first) System.out.println();
			first = false;
			StringBuffer num = new StringBuffer(sc.next());
			while (num.length() < 5)
			{
				num.insert(0, '0');
			}
			for (int i = 0; i < 8; i++)
			{
				for (int j = 0; j < 5; j++)
				{
					System.out.print(pattern[num.charAt(j)-'0'].charAt(i));
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s;
  cin >> s;
  int res = 0;
  switch (s[0]) {
    case 'M':
      res = 6;
      break;
    case 'W':
      res = 4;
      break;
    case 'F':
      res = 2;
      break;
    case 'T':
      if (s[1] == 'U')
        res = 5;
      else
        res = 3;
      break;
    case 'S':
      if (s[1] == 'A')
        res = 1;
      else
        res = 7;
      break;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

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


using namespace std;


int main()
{
    int N;
    long long int Z, W;
    long long int a[2001];

    scanf("%d %ld %ld", &N, &Z, &W);
    REP(i, N) {
        scanf("%ld ", &a[i]);
    }

    long long int ans = 0;

    if (N==1)
        ans = abs(a[N-1]-W);
    else
        ans = max(abs(a[N-1]-W), abs(a[N-1]-a[N-2]));

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
def Warshall_Floyd(edges,N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                edges[i][j]=min(edges[i][j],edges[i][k]+edges[k][j])
    return edges


def main():
    H,W = map(int,input().split())
    ls = [list(input()) for _ in range(H)]
    for i in range(H):
        ls[i].insert(0,"#")
        ls[i].append("#")
    ls.append(["#" for _ in range(W+2)])
    ls.insert(0,["#" for _ in range(W+2)])
    graph = [[float("inf") for _ in range(H*W)] for _ in range(H*W)]

    for i in range(1,H+1):
        for j in range(1,W+1):
            if ls[i][j]==".":
                # ue
                if ls[i-1][j]==".":
                    graph[(i-1)*W+(j-1)][(i-2)*W+(j-1)] = 1
                    graph[(i-2)*W+(j-1)][(i-1)*W+(j-1)] = 1
                # migi
                if ls[i][j+1]==".":
                    graph[(i-1)*W+(j-1)][(i-1)*W+j] = 1
                    graph[(i-1)*W+j][(i-1)*W+(j-1)] = 1
                # sita
                if ls[i+1][j]==".":
                    graph[(i-1)*W+(j-1)][i*W+(j-1)] = 1
                    graph[i*W+(j-1)][(i-1)*W+(j-1)] = 1
                # hidari
                if ls[i][j-1]==".":
                    graph[(i-1)*W+(j-1)][(i-1)*W+(j-2)] = 1
                    graph[(i-1)*W+(j-2)][(i-1)*W+(j-1)] = 1
                else:
                    pass

    a = Warshall_Floyd(graph,H*W)
    for i in range(H*W):
        for j in range(H*W):
            if a[i][j]==float("inf"):
                a[i][j]=0
    for i in range(H*W):
        a[i][i] = 0

    mx = 0
    for i in a:
        mx = max(mx,max(i))
    print(mx)
if __name__ == '__main__':
    main()

Measured memory_bytes: 134792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll n;
ll a[200005];
ll b[200005];
ll c[200005];
ll dp[200005][4];
ll recurse(ll day,ll prev){
    if(day==n){
    	if(prev==1){
    		return max(b[day],c[day]);
		}
		else if(prev==2){
			return max(a[day],c[day]);
		}
		else{
				return max(b[day],a[day]);
			}
		}
		if(dp[day][prev]!=-1)
		  return dp[day][prev];
		//if(prev==0){
			//return max(recurse(day+1,1),max(recurse(day+1,2),recurse(day+1,3)));
	//	}
		if(prev==1){
			return dp[day][prev]=max(b[day]+recurse(day+1,2),c[day]+recurse(day+1,3));
		}
		else if(prev==2){
			return dp[day][prev]=max(a[day]+recurse(day+1,1),c[day]+recurse(day+1,3));
		}
		else if(prev==3){
			return dp[day][prev]=max(b[day]+recurse(day+1,2),a[day]+recurse(day+1,1));
		}
}
int main()
    {
       ios_base::sync_with_stdio(false);
        cin.tie(0);
        ll i,j,k,l,m;
        cin>>n;
        for(i=1;i<=n;i++){
        	dp[i][1]=-1;
        	dp[i][2]=-1;
        	dp[i][3]=-1;
		}
        for(i=1;i<=n;i++){
        	cin>>a[i]>>b[i]>>c[i];
		}
		ll maxi=max(recurse(1,1),max(recurse(1,2),recurse(1,3)));
		cout<<maxi;
    	return 0;
}


Measured memory_bytes: 13184
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

import java.util.Arrays;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final int ALPHA = 26;

        BufferedReader reader = new BufferedReader(
            new InputStreamReader(System.in));

        String s = reader.readLine();

        int n = Integer.parseInt(s);

        int[] min = new int[ALPHA];

        Arrays.fill(min, Integer.MAX_VALUE);

        for (int i = 0; i < n; i++) {
            s = reader.readLine();

            int[] cur = new int[ALPHA];

            Arrays.fill(cur, 0);

            for (int j = 0; j < s.length(); j++) cur[s.charAt(j) - 'a']++;

            for (int j = 0; j < ALPHA; j++) min[j] = Math.min(min[j], cur[j]);

        }

        PrintWriter out = new PrintWriter(System.out);

        for (int i = 0; i < ALPHA; i++) {
            int num = min[i];
            for (int j = 0; j < num; j++) out.print((char)('a' + i));
        }

        out.println();

        out.flush();
    }
}


Measured memory_bytes: 23508
N = int(input())
x = list(map(int, input().split()))

p = sum(x) / N
p0 = p - int(p)

if p0 <= 0.5:
    p = int(p)
else:
    p = int(p) + 1

ans = 0
for i in x:
    ans += (p - i) ** 2

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1000000000
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int a, b;

signed main() {
	cin >> a >> b;
	if (abs(a - b) % 2)cout << "IMPOSSIBLE" << endl;
	else cout << (a + b) / 2 << endl;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;

int n,ans = 0;
int main(){
	cin >> n;

	rep(i,0,n){
		int tmp = i+1;
		int c = 0;
		while(tmp%2 == 0){
			tmp = tmp/2;
			c++;
		}
		ans = max(ans,c);		
	}
	int a = 1;
	rep(i,1,ans+1){
		a *= 2;
	}
	pout(a);
	return 0;
}


Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        break

Measured memory_bytes: 7588